Autonomous lottery with a new round starting every 10th block. Winners are determined by hashing player addresses and need not be stored in contract state. This can be manipulated by miners so the project is not ready for mainnet yet.
Rinkeby testnet deploy: https://autonomous-lottery-dapp.vercel.app
Hardhat Network is used to run and debug Solidity locally, along with Typechain to provide TypeScript bindings for Ethereum smart contracts.
Patterns applied:
Ethers library is used to interact with the blockchain.
External & public contract functions are covered by Waffle tests.
Next.js hits Infura on SSR to render the latest lottery info (rounds, players, payouts, winners) for browsers with no Ethereum provider like Metamask installed. Metamask is only required to interact with the lottery.
Frontend uses context provider with React Hooks pattern for global store, initialized (hydrated) from SSR, and then updated on contract events.
Tailwind is used for layout, and Ant Design for UI components.
All code across Next.js, React, Hardhat scripts and tests is statically typed with TypeScript.
npm i
npm run node
starts Hardhat Networknpm run deploy
deploys the Lottery contract & makes some transactions for testingnpm run dev
starts Next.js- Install Metamask