A transparent, blockchain-based lottery platform that allows multiple lottery instances to run simultaneously. Built with Solidity and React, this DApp features a persistent "Hall of Fame," a global identity system, and a trustless "Timer" mechanism, and a Dashboard for viewing your stats.
- Contract Address:
0x18bf25cC35163D36f19bEB16E61811d91cF50A7C - Status: Live 🟢
- Multi-Lottery Architecture: Support for running multiple lottery rounds concurrently with different prices and durations.
- Global Identity System: Users can register a unique nickname that persists across all lotteries.
- Trustless Execution: If a lottery timer expires, any user can trigger the "End Lottery" function, ensuring funds are never locked if the admin goes offline.
- Player Dashboard: Personal stats tracking Total ETH Spent, Total Won, and Net Profit/Loss.
- Transparency Mode: Full history of every player and transaction is visible even after a lottery ends.
To make this application work, you must deploy the Smart Contract to the Sepolia Testnet.
- MetaMask Wallet installed in your browser.
- Sepolia ETH (Testnet funds). You can get this for free from faucets like Google Cloud Web3 Faucet or Alchemy.
- Go to Remix IDE.
- Create a new file named
LotteryManager.solinside thecontractsfolder. - Paste the Solidity code provided in this project.
- Go to the Solidity Compiler tab (left sidebar) and click Compile.
- Go to the Deploy & Run Transactions tab.
- Change Environment to
Injected Provider - MetaMask. - Approve the connection in your MetaMask pop-up.
- Click Deploy (orange button) and confirm the transaction.
- Change Environment to
- Once deployed, look at "Deployed Contracts" at the bottom left. Copy the Contract Address.
Now that the contract is on the blockchain, you need to connect the React app to it.
Open your terminal in the project folder and run:
npm installOpen the file src/contractConfig.js in your code editor. You need to update two things:
- Address: Paste the address you copied from Remix.
- ABI: Copy the ABI from Remix (Compiler Tab -> "ABI" button) and paste it here.
It should look like this:
export const CONTRACT_ADDRESS = "0x123456789..."; // Your new address
export const ABI = [ ... ]; // Your new ABIStart the local development server:
npm run devOpen http://localhost:5173 in your browser.
- Connect the wallet that deployed the contract.
- Click the "🔑 Admin" button in the header.
- Set a Ticket Price (e.g., 0.01 ETH) and Duration (e.g., 10 minutes).
- Click Launch to start a new round.
- Connect your MetaMask wallet.
- Go to the Identity panel and set a unique nickname.
- Browse active lotteries in the Lobby.
- Select ticket quantity and click Buy.
- Wait for the timer to end or verify winners in the Hall of Fame!