This repo contains coursework project from LearnWeb3 completed by 0xsenzel for LearnWeb3DAO-Junior lesson.
Randomness source from Chainlink VRF V2 to pick random winner for lottery game. Log the winners using The Graph Indexing.
Fig.1 - Home Page
Fig.2 - Connected with wallet
Fig.3 - Connect with Owner's Wallet to Start Game
Fig.4 - Home Page View Once Game Started
Note
Under the situation were you were unable to join, adjust your "Gas Limit" ; "Max Priority Fee" ; "Max Fee" accordingly. Here's a guide on how to adjust on Metamask.
Head to hardhat-tutorial folder:
Install dependencies
npm install
Compile smart contract
npx hardhat compile
To deploy smart contracts:
Head to hardhat.config.js file, change the value of:
ALCHEMY_HTTP_URLwith your own Ethereum Network APIPRIVATE_KEYwith your Ethereum wallet's private keyPOLYGONSCAN_API_KEYwith your Etherscan's API Key
Then run the following command.
npx hardhat run scripts/deploy.js --network goerli
npx hardhat verify --network mumbai YOUR_SMARTCONTRACT_ADDRESS "CONSTRUCTOR ARG1" "CONSTRUCTOR ARG2"
Head to graph folder:
npm install
Create an account and setup your Subgraph Indexing. Here are some of the command you can use to setup locally:
yarn global add @graphprotocol/graph-cli
graph init --contract-name RandomWinnerGame --product hosted-service GITHUB_USERNAME/Learnweb3 --from-contract YOUR_RANDOM_WINNER_GAME_CONTRACT_ADDRESS --abi ./abi.json --network mumbai graph
graph auth
yarn codegen
yarn deploy
Head to my-app folder:
npm install
Replace the variable inside this file:
RANDOM_GAME_NFT_CONTRACT_ADDRESSwith your deployed smart contract address.
Replace SUBGRAPH_URL located in this file with your own link at The Graph Dashboard.
To run the app locally:
npm run dev