A decentralized lottery application using Solidity smart contracts, Chainlink VRF for randomness, and a modern Next.js frontend. This project ensures transparent, verifiable draws and automated prize distribution without intermediaries.
.
βββ .env* / .gitignore # Environment & ignore files
βββ assets/ # Static images used in frontend
βββ components/ # React components for Next.js app
βββ contracts/ # Solidity smart contracts
βββ deploy/ # Hardhat deploy scripts (mock + production)
βββ offchain/ # Off-chain utility (e.g., Supabase client)
βββ pages/ # Next.js pages including routes and API handlers
β βββ api/ # API endpoints
β βββ jackpots/ # Jackpot detail pages
β βββ results/ # Result detail pages
βββ public/ # Public assets (favicon, etc.)
βββ scripts/ # Utility scripts
βββ services/ # Blockchain-related logic (frontend/backend separation)
βββ store/ # Redux global state management
β βββ actions/ # Redux actions
β βββ states/ # Initial/global states
βββ styles/ # CSS modules and global styles
βββ test/ # Hardhat tests
βββ hardhat.config.ts # Hardhat config (network, plugins, etc.)
βββ tsconfig.json # TypeScript config
βββ yarn.lock / package.json # Project and workspace config
- Node.js v18.12.1 (strict requirement)
- Yarn (v3.2.3 or higher)
Run from the project root:
yarn installThis installs dependencies for both the Hardhat backend and the frontend/ workspace.
yarn hardhat node --no-deployThis script starts the local Hardhat node
Please create a .env.localhost.local file, where you define LOCALHOST=http://127.0.0.1:8545. The rest of the
necessary variables will be set (e.g. by yarn extract:local-keys).
yarn run:localThis script deploys the contracts on the local chain and starts the web server.
Manually add the network:
- Network Name:
Hardhat Localhost - RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337
Copy one of the printed private keys from your terminal and import it in MetaMask under "Import Account".
This project uses Supabase to store uploaded jackpot images and optionally store metadata in a table.
- Create a Supabase project at https://app.supabase.com
- Create a public bucket in Storage named
jackpot-images - (Optional) In Database, create a table
jackpot_imagesto store metadata likeurl,filename, etc. - Get your keys under Project Settings β API:
- SUPABASE_URL β your projectβs URL
- SUPABASE_ANON_KEY β for safe frontend access
- SUPABASE_SERVICE_ROLE_KEY β for backend-only DB access (
β οΈ keep secret)
Add the following to your .env.local:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-keyGo to http://localhost:3000 and start creating/joining lotteries.
To deploy to Sepolia testnet:
Create a .env.sepolia.local file:
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/<YOUR_INFURA_KEY>
SEPOLIA_PRIVATE_KEY=0x...
VRF_COORDINATOR=...
VRF_KEYHASH=0x...
VRF_SUBSCRIPTION_ID=...You can get your VRF Subscription here.
yarn run:sepoliaThis script:
- Sets the correct environment
- Deploys contracts to Sepolia
- Starts the frontend locally
Then visit: http://localhost:3000
Connect MetaMask to Sepolia and use a funded test account.
yarn compileyarn cleanyarn deploy:localSplit steps:
yarn deploy:local:mocksyarn deploy:local:lotteryyarn testyarn lintyarn format- Transparent and fair lottery system
- On-chain randomness via Chainlink VRF
- Automated prize payout via smart contracts
- Clean dApp architecture with separation of concerns