After spending time learning Solidity using Foundry, I’ve just completed a practical project to consolidate my knowledge.
🎯 Project: Raffle DApp – A Decentralized Lottery Smart Contract
This project helped me apply core Web3 concepts in a real-world scenario.
🔗 Tech Stack Used
Chainlink VRF v2 — For verifiable, tamper-proof randomness
Chainlink Automation — To automate on-chain upkeep logic
Foundry — For testing, scripting, and deploying smart contracts
Solidity — Of course 😄
💡 How It Works
Users call enterRaffle() and send ETH to participate
At intervals, Chainlink Automation triggers performUpkeep() if conditions are met
Chainlink VRF returns a random number to select the winner
ETH is transferred to the selected wallet
✅ Key Improvement
To prevent spam and ensure fairness:
Each wallet is limited to 3 entries per round
This required additional validation logic and state tracking.
🧪 What I Learned
Writing secure logic to validate raffle states
Limiting wallet participation per round
Creating test scenarios for edge cases
Using HelperConfig to deploy across networks (localhost, Sepolia, etc.)
Automating VRF Subscription creation/funding
Mocking contracts, simulating time, improving test coverage
💻 Source Code
GitHub Repo:
🔗 https://github.com/ErwinPham/my-lottery-foundry
Contract (Deployed):
📜 0x48f945DEFA...F02889D7
🙏 Credit
Special thanks to @patrickalphac and the amazing course from Cyfrin Updraft for providing top-tier learning content!
🤝 Let’s Connect!
If you’re working on Web3, Solidity, Chainlink or Foundry — I’d love to learn and collaborate!
🏷️ Tags
Top comments (1)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.