{"id":26897048,"url":"https://github.com/yug49/lottery-smartcontract-foundry","last_synced_at":"2026-04-30T00:08:05.528Z","repository":{"id":284281119,"uuid":"954423464","full_name":"yug49/Lottery-SmartContract-Foundry","owner":"yug49","description":"Different players can enter the raffle by paying an entrance fees and a random winner is picked and the price pool (all the entrance fees combined) is given to the winner.","archived":false,"fork":false,"pushed_at":"2025-03-25T04:05:34.000Z","size":27872,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T05:19:19.368Z","etag":null,"topics":["automation","blockchain","smart-contracts","solidity","vrf"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yug49.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-25T04:04:16.000Z","updated_at":"2025-03-25T04:37:09.000Z","dependencies_parsed_at":"2025-03-25T05:34:54.513Z","dependency_job_id":null,"html_url":"https://github.com/yug49/Lottery-SmartContract-Foundry","commit_stats":null,"previous_names":["yug49/lottery-smartcontract-foundry"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yug49%2FLottery-SmartContract-Foundry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yug49%2FLottery-SmartContract-Foundry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yug49%2FLottery-SmartContract-Foundry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yug49%2FLottery-SmartContract-Foundry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yug49","download_url":"https://codeload.github.com/yug49/Lottery-SmartContract-Foundry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586105,"owners_count":20801026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","blockchain","smart-contracts","solidity","vrf"],"created_at":"2025-04-01T04:33:15.270Z","updated_at":"2026-04-30T00:08:05.489Z","avatar_url":"https://github.com/yug49.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Smart-Contract-Lottery\nIt is a smart contract project written in [Solidity](https://docs.soliditylang.org/en/latest/) using [Foundry](https://book.getfoundry.sh/).\n- It a smart contract I developed leveraging Foundry.\n- It implements a raffle-lottery system.\n- Different players can enter the raffle by paying an entrance fees and a random winner is picked and the price pool (all the entrance fees combined) is given to the winner.\n- It leverages [Chainlink VRF](https://vrf.chain.link/) to implement randomness in picking the winner and [Chainlink Automation](https://automation.chain.link/) to automate this smart contract.\n\n\n## Getting Started\n\n - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git): You'll know you did it right if you can run `git --version` and you see a response like `git version x.x.x`\n - [foundry](https://getfoundry.sh/): You'll know you did it right if you can run `forge --version` and you see a response like `forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)`\n - [make](https://www.gnu.org/software/make/manual/make.html) (optional - either you can install `make` or you can simply substitute the make commands with forge commands by referring to the Makefile after including your .env file): You'll know you did it right if you can run `make --version` and you will see a response like `GNU Make 3.81...`\n\n \n## Installation\n\n- Install Lottery-SmartContract-Foundry\n```bash\n    git clone https://github.com/yug49/Lottery-SmartContract-Foundry\n    cd Lottery-SmartContract-Foundry\n```\n\n- Make a .env file\n```bash\n    touch .env\n```\n\n- Open the .env file and fill in the details similar to:\n```env\n    SEPOLIA_RPC_URL=\u003cYOUR SEPOLIA RPC URL\u003e\n    ETHERSCAN_API_KEY=\u003cYOUR ETHERSCAN API KEY\u003e\n    SEPOLIA_PRIVATE_KEY=\u003cYOUR PRIVATE KEY\u003e\n```\n- Remove pre installed cache, unecessary modules etc.\n```bash\n    make clean\n    make remove\n```\n\n- Install dependencies and libraries.\n```bash\n    make install\n```\n\n- Build Project\n```bash\n    make build\n```\n\n\n\n    \n## Deployment\n\n### Deploy On a Local Network (Anvil Testnet)\n- To Deploy on a local network first run anvil on your local terminal in current directory by running coommmand: ` make anvil`.\n- Now open another terminal and let this one run in the background\n- Run the following command:\n```bash\nmake deploy\n```\n\n### Deploy on a Sepolia or Any Other Network\n- To Deploy on Sepolia, after successfully creating .env file as mentioned above.\n- Get youself some Sepolia Eth and LINK tokens and then run command:\n```bash\nmake deploy ARGS=\"--network sepolia\"\n```\n- register a Chainlink Automation Upkeep - [Documentation](https://docs.chain.link/chainlink-automation/compatible-contracts) \n- Go to [automation.chain.link](https://automation.chain.link/new) and register a new upkeep, enter your deployed contract Address. Choose Custom logic as your trigger mechanism for automation. Your UI will look something like this once completed:\n![Automation](./img/ChainlinkAutomationExample.png)\n- Enter a name of the upkeep and fund it with, lets say 3 LINK.\n- You can put in your email and name too(optional).\n\n## Scripts\n\n- After deploying to a testnet or local net, you can run the scripts.\n\n= Using cast deployed locally example:\n\n```bash\ncast send \u003cRAFFLE_CONTRACT_ADDRESS\u003e \"enterRaffle()\" --value 0.1ether --private-key \u003cPRIVATE_KEY\u003e --rpc-url $SEPOLIA_RPC_URL\n```\n\nor, to create a ChainlinkVRF Subscription:\n\n```bash\nmake createSubscription ARGS=\"--network sepolia\"\n```\n\n### You can also use Etherscan to interact with the contract:\n\n- Open [sepolia.etherscan.io](https://sepolia.etherscan.io/).\n- Search your contract address.\n- Click on Contract tab \u003e Read Contract / Write Contract.\n- Connect your web3 wallet.\n\n### How it Works?\n- Once a player enters the Raffle, after a fixed interval of time(can be altered in `./script/HelperConfig.s.sol`), the Chainlink Automation Upkeep runs `Raffle::checkUpkeep()` function.\n- If it returns true, it automatically runs `Raffle::performUpkeep()` function to generates a random number cytrographically through Chainlink VRF oracle service and picks a winner.\n\n\n\n## Estimate gas\nYou can estimate how much gas things cost by running:\n```bash\nmake snapshot\n```\n\n## Testing\n\n- for local anvil\n```bash\n    make test\n```\n\n## Formatting\n- to format all the solidity files:\n```bash\n    make format\n```\n\n\n## Coverage\n- To get test coverage report.\n```bash\nmake test-coverage\n```\n\n\n\n\n## 🔗 Links\nLoved it? lets connect on:\n\n[![twitter](https://img.shields.io/badge/twitter-1DA1F2?style=for-the-badge\u0026logo=twitter\u0026logoColor=white)](https://x.com/yugAgarwal29)\n[![linkedin](https://img.shields.io/badge/linkedin-0A66C2?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white)](https://www.linkedin.com/in/yug-agarwal-8b761b255/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyug49%2Flottery-smartcontract-foundry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyug49%2Flottery-smartcontract-foundry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyug49%2Flottery-smartcontract-foundry/lists"}