This is a proofably random smart contract lottery built with foundry. This project is a smart contract lottery using Chainlink VRF to determine a random winner. Chainlink automation is used to call the functions to determine the winner. This project does also include the relevant tests.
- Users can enter by purchasing a ticket
- After a specific time period the lottery will draw a winner
- This will be done with ChainLink Automation (Time based trigger) and VRF (verifiable randomness)
- The winner will receive all ticket fees gathered.
- Foundry (Smart Contract Development Framework)
- Chainlink-Brownie-Contracts (Chainlink Smart Contracts)
- Chainlink-VRF (Chainlink´s Verifiable Random Function)
- Chainlink-Automation
If you want to clone this project run the following command
$ forge init
$ make install
$ forge build
$ forge test
Run test with matching function
$ forge test --match-test <testYourTestName>
Test how much of your contracts your test cover by running this command:
$ forge coverage
get more inforamtion on what functions still need to be tested and output it to coverage.txt
$ forge coverage --report debug > coverage.txt
Debug tool; With this you can navigate throught your contract opcode
$ forge test --debug <testYourTestName>
You can estimate how much gas things cost by running:
$ forge snapshot
$ anvil
$ forge script script/DeployRaffle.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key>
or use the commands in the makefile
here make sure to start up Anvil before running this command
$ make deploy
$ make deploy ARGS="--network sepolia"
After deploying the contract you must manually register a new Upkeep on Chainlink Automation using the contract address!
You can interact with your contracts from the command line useing cast
$ cast <subcommand>