Skip to content

kushaln3/Lottery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

⚡ Decentralized Multi-Lottery Protocol

Solidity React Ethereum

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.

🔗 Current Deployment (Sepolia Testnet)

  • Contract Address: 0x18bf25cC35163D36f19bEB16E61811d91cF50A7C
  • Status: Live 🟢

🚀 Key Features

  • 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.

image

🛠️ Step 1: Deploying the Smart Contract (Sepolia)

To make this application work, you must deploy the Smart Contract to the Sepolia Testnet.

Prerequisites

  1. MetaMask Wallet installed in your browser.
  2. Sepolia ETH (Testnet funds). You can get this for free from faucets like Google Cloud Web3 Faucet or Alchemy.

Deployment Steps (Using Remix IDE)

  1. Go to Remix IDE.
  2. Create a new file named LotteryManager.sol inside the contracts folder.
  3. Paste the Solidity code provided in this project.
  4. Go to the Solidity Compiler tab (left sidebar) and click Compile.
  5. 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.
  6. Once deployed, look at "Deployed Contracts" at the bottom left. Copy the Contract Address.

💻 Step 2: Setting up the Frontend

Now that the contract is on the blockchain, you need to connect the React app to it.

1. Install Dependencies

Open your terminal in the project folder and run:

npm install

2. Configure the Contract

Open 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 ABI

3. Run the App

Start the local development server:

npm run dev

Open http://localhost:5173 in your browser.


🎮 How to Use

For Admin (The Deployer)

  1. Connect the wallet that deployed the contract.
  2. Click the "🔑 Admin" button in the header.
  3. Set a Ticket Price (e.g., 0.01 ETH) and Duration (e.g., 10 minutes).
  4. Click Launch to start a new round.

For Players

  1. Connect your MetaMask wallet.
  2. Go to the Identity panel and set a unique nickname.
  3. Browse active lotteries in the Lobby.
  4. Select ticket quantity and click Buy.
  5. Wait for the timer to end or verify winners in the Hall of Fame!

About

A Decentralised Lottery Manager Web3 DApp deployed on Ethereum Blockchain developed using Solidity and React.js

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors