Hoelee Smart Contract - Automate Lottery
📚 A Learning Project
Note from Hoelee 👋 — This is part of my journey exploring Web 3.0 / blockchain development. I'm a hands-on self-taught developer learning Solidity and smart-contract engineering by building real, working projects — not just following tutorials. This lottery contract is one of my practice builds: it walks through the full modern Web3 stack end-to-end, from writing the contract, to testing it (Hardhat and Foundry), to deploying and verifying on a public testnet with Chainlink automation. Consider it my learning project note — documenting what I'm studying, how I build, and the standards I hold myself to. It grows as I learn. 🚀
Grand Porject Overview
This Project Smart Contract Created With
SolidityContract +Hardhat+node.jsfor TestSolidityContract & Test +Foundry
Hardhat Project
A fully functional Smart Contract wrriten with solidity, node.js and using Hardhat to show usage of all kinds of standard development features, including:
- running blockchain node in localhost -
hardhat&ganache - solidity prettier code beautifier setup
- standard of developing Smart Contract with
solidity - standard of developing
node.jsscript to usehardhatlibrary efficiently - check gas fee & gas price in real-time, with usage of
coverage - auto verify contract on Etherscan.io
- creating automate test cases - unit test & staging test
- creating tasks etc.
- refactor codes to reduce gas fee
- write code in best practice, with usage of
solhint - prettier
solidity&node.jscode - gitea version control
This project mainly to keep as a reference for future Web 3.0 Developments.
Read More in Hardhat Project's Note Page.
Foundry Project
Same Lottery Project, Use Of Solidity to test smart contract, ensure high coverage of function correctness. Feature included:
- Modular Enable Test In Multiple Networks With Different Conditions
- Local Network Using Of Anvil + Mock VRF (Verifiable Randomness Function)
- Testnet Use of Latest V2.5 Chainlink VRF Subscription With Consumer Subscription
- Use of Custom LinkToken on Sepolia Testnet
- Smart Contract Test With High Coverage To Ensure Correctness
- Private Key Encrypted With Keystore, Safer Usage With Password
- Smart Contract Layer-2 Ready (ZKsync)
Read More In Foundry Project's Note Page.
Success Deploy & Verified Smart Contract In Sepolia Testnet
0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4 https://sepolia.etherscan.io/address/0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4#code Via deploy.js https://sepolia.etherscan.io/address/0x3a827C119e1D746bb3C7bcbbf95c55246C8CcBdd#code Via yarn hardhat deploy --network sepolia
Public Reported Hacked Code References:
This website is records of all kind previous hacked smart contract:
https://rekt.news/leaderboard/
1. Understanding Of Known Vulnerabilities
- Reentrancy Attack
- Locked with modifier while running withdraw function
- Update variable immediately before call external function
- Integer Overflow / Underflow
- Use compiler version >0.8.0 have check in place
- Front-Running
- Use average gas fee / off peak times
- Use commit-reveal schema
- Use submarine send
2. Other Explored Features
- Generate Random Words
- Create subscription at https://vrf.chain.link/ (MetaMask #1)
- Add Fund To The Created Subsciption Contract (MetaMask #2)
- Add Consumer
- Get Subscription ID
- Open Remix To Prepare Deploy Consumer Contract https://docs.chain.link/vrf/v2-5/migration-from-v2
- Change To Correct gwei limit hash address at https://docs.chain.link/vrf/v2/subscription/supported-networks
- Adjust Setting - random words count, confirmation blocks etc.
- Insert Subscription ID - v2 is uint64 BUT v2.5 is uint256
- Deploy And Get hash address (MetaMask #3)
- Insert in chainlink consumer (Metamask #4)
- Ready to use, record down the consumer contract address
- New Time Based Trigger Automation Through Chainlink UpKeep
- Same As VRF Subscription, V2.5 Optional Reduced Steps
- Setup At https://automation.chain.link/
- After Subscription Created, Funded, & Setup Interval:
- VRFCoordinator will call checkUpkeep(bytes memory checkData)
- checkUpkeep true will call internal contract performUpkeep(bytes calldata performData)
3. Looking Web 3.0 Developer For Your Project?
👨💻 About Hoelee — I'm actively exploring Web 3.0 and blockchain development while continuing my work in web development and self-hosting. I'm a dedicated, self-motivated learner who picks projects apart, understands how they work, and ships real code — not just concepts.
Mr Hoelee is welcoming a 💼 Web 3.0 / blockchain Remote Job — especially entry/junior roles, internships, or a learning-oriented opportunity where I can grow and contribute. Let's talk! Contact me immediately via WhatsApp +601****5290
Or you can email me@hoelee.com now. Thanks.
Check out my portfolio at hoelee.com to see more of what I build.
4. Like this project?
If you are feeling generous, buy me a coffee! - buymeacoffee.com/hoelee