You can play with this in remix here
A web3 implementation of a decentralized provably random lottery using Chainlink VRF and Chainlink alarm clock to have a totally decentralized lottery. Check the ETH readme for how to do the truffle stuff.
- Compile all contracts and interfaces
- Deploy the governance contract
- Deploy the randomness contract with the governance contract address as a parameter
- Deploy the lottery contract with the governance contract address as a parameter
- call the governance function
init
with the lottery address, followed by the randomness address as parameters - fund the randomness and lottery contract with some LINK
- Call the
start_new_lottery
function, with a duration you'd like it to last in seconds. - Enter the lottery and have fun.
- After the duration is up, the winner should be automatically randomly chosen via Chainlink VRF - and the lottery will totally reset, so you can start another one.
You'll notice there are a few permission hiccups, but this is a beta so whatever.
git clone <this_repo>
cd chainlink-lottery
npm install
Make sure you have RPC_URL
and MNEMONIC
in your environment variables
Setup:
npx create-react-app chainlink-lottery
cd chainlink-lottery
mkdir ethereum
cd ethereum
truffle unbox smartcontractkit/box
truffle migrate --network live
- Fix all the permission issues (random people can break the lottery at the moment, should be an easy fix)
- Add more VRF nodes to decentralize the random number part
- Add more Alarm clocks to decentralize the alarm clock part
- Write tests
- write scripts to make stuff easier
- Cool frontend