How phucthanh3a/web3-lottery-dapp-reactjs works
Project type and purpose
• This is a React-based decentralized application (dApp) whose sole purpose is to serve as the front-end for a “Lottery” smart contract on the Ethereum blockchain. Users connect via MetaMask, enter the lottery by sending ETH, and the contract owner picks a winner.
File structure
• Top-level files:
• package.json / package-lock.json – lists dependencies (React, web3 or ethers).
• public/index.html, manifest.json, robots.txt – static HTML entry point.
• src/ directory:
• App.js / App.css – bootstraps the React single-page application.
• Home.js – shows manager, players, balance, and a form to enter the lottery.
• PickWinner.js – shows a button for the manager to pick a winner.
• constants.js – exports contract ABI and the deployed contract address.
• index.js, reportWebVitals.js, setupTests.js – standard CRA scaffolding.
README for additional insights
• Smart contract source (Lottery.sol) must be compiled in Remix to obtain the ABI.
• Deployment via Injected Provider (MetaMask), copy resulting address into src/constants.js.
• Front-end communicates directly with the deployed contract on localhost:3000.
Capturing essential architectural elements
• Distinguish between “read” vs. “write” contract interactions.
• Role of constants.js as the source of truth for ABI & contract address.
• Call out that transaction signing is always mediated by MetaMask.
• User role (Manager vs. Participant) if space allows, to show PickWinner is manager-only.