The above code sample is written in solidity, Traditional lotteries often lack transparency, leaving room for manipulation. So, I have created a project that is a decentralized lottery system using ensures fairness and transparency for all participants. Players can participate by paying for tickets. Integrating it with Chainlink VRF ensures a truly random winner is picked. Automating it by using chainlink automation, ensures that automatically winner will be picked and the winning amount will be transferred to the winner automatically, hence making is more advanced.
- User can enter by paying for a ticket. The ticket fee are going to go to winner during the draw .
- After X period of time lottery will automatically draw a winner.
- Using chainLink VRF and chainLink Automation. ChainLink VRF - It will be used to find randomness (number) ChainLink Automation - Time based trigger
You'll know you did it right, if can run git --version and you see a response like git version x.x.x .
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)
To clone this Repo use command -
git clone https://github.com/hoBabu1/Raffle_Smart_Contract-Foundry-.git
If you're having a hard time installing the chainlink library, you can optionally run this command.
forge install smartcontractkit/[email protected] --no-commit
This will default to your local node. You need to have it running in another terminal in order for it to deploy.
make deploy
- Setup environment variables
You'll want to set your SEPOLIA_RPC_URL
and PRIVATE_KEY
as environment variables. You can add them to a .env file.
PRIVATE_KEY
: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.
SEPOLIA_RPC_URL
: This is url of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy.
Optionally, add your ETHERSCAN_API_KEY
if you want to verify your contract on Etherscan.
-
Get testnet ETH Head over to faucets.chain.link and get some testnet ETH. You should see the ETH show up in your metamask.
-
Deploy on Sepolia testnet, just run this command (make sure you have rpc url , private key in your .env file)
make deploy ARGS="--network sepolia"
- Register a Chainlink Automation Upkeep
Go to automation.chain.link and register a new upkeep. Choose Custom logic as your trigger mechanism for automation.
If you think there could be some changes feel free to create a issue .