This project is a blockchain-based lottery which allows users to enter by paying the entry fee of $50 USD. The winner is determined by obtaining a verifiably random number from a Chainlink oracle, and paying out the contract balance to the corresponding user. The purpose of this project is to gain experience with powerful tools such as Hardhat, Chainlink and OpenZeppelin.
- Clone the repository
- Run
npm install
- Create a
secrets.json
file with the following contents:
{
"alchemyMainnetUrl": "",
"alchemyRinkebyUrl": "",
"rinkebySecretKey": ""
}
- Open a terminal window and run
npx hardhat node
- Open a second terminal window
- Run
npx hardhat run scripts/deploy.js --network localhost
- Note the addresses of the Lottery and LinkToken contracts
- Unit test: run
npx hardhat test
- Integration test: run
npx hardhat run test/test_lottery_integration --network rinkeby
- Run
npx hardhat startLottery <Lottery address> --network localhost
- Run
npx hardhat enterLottery <Lottery address> --network localhost
- Run
npx hardhat fundWithLink <Lottery address> <LinkToken address> --network localhost
- Run
npx hardhat endLottery <Lottery address> --network localhost