Simple Lottery is a decentralized take on reddit's /r/millionairemakers. A player can purchase a lottery ticket with a "one ticket per address" limitation. When all the tickets are sold, the winning number is drawn via Chainlink VRF. The total prize pool is then automatically fowarded to the winner.
0x9d3aDec7fb41447f1e744Fd3e73520AEf19Cc551
Visit https://blockchain-developer-bootcamp-final-project-6a69w4aq1-xoddong.vercel.app/
Part 1: https://www.loom.com/share/3b79fe9ffc3d41c584a06154014ee0b6?sharedAppSource=personal_library Part 2: https://www.loom.com/share/1c8917da1b78474aad2ff444369f7622?sharedAppSource=personal_library
git clone https://github.com/xoddong/blockchain-developer-bootcamp-final-project
cd blockchain-developer-bootcamp-final-project
# install
yarn installIf you see the following error, please try running yarn install with nvm
error hardhat@2.7.0: The engine "node" is incompatible with this module.yarn compileHardhat produces an artifacts directory for all the contrat builds. This project has configured the artifacts directory path to be "./client/src/artifacts" via hardhat.config.ts
yarn deploy:kovanWhen deploying the contracts, please utilize the yarn commands. The yarn commands add the flag --export-all to produce a mapping of all the contracts. The frontend utilizes these files to get the deployed contract address
yarn testRunning the test will:
- Deploy the contracts that match the fixture
await deployments.fixture(["lottery"]); // deploys files that have the matching tag: "lottery"- Runs the test
To deploy to a testnet or a live network, you need the following environment variables:
- KOVAN_RPC_URL=https://eth-ropsten.alchemyapi.io/v2/
- PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
Your KOVAN_RPC_URL is the URL of your blockchain node, for example, from alchemy.
Your MNEMONIC is the mnemonic phrases of your MetaMask.
You can set them in a file named .env. Please make sure you do not commit this file.
You'll also need testnet ETH and testnet LINK. You can find both here.
Once you do so, you can run:
yarn deploy:kovan
Fund your contract with LINK.
npx hardhat fund-link --contract insert-contract-address-here --network kovan
And purchase a lottery ticket
npx hardhat run scripts/purchaseTicket.ts --network kovan
You can interact with the deployed contract on Kovan in our client app. To start the app:
cd client
yarn install
yarn startTo deploy your own instance to work with in local client, first compile and redeploy a new contract.
yarn compile
yarn deploy:kovan
npx hardhat fund-link --contract {NEW_CONTRACT_ADDRESS} --network kovan
cd client
yarn install
yarn start