/lottery-dapp

Lottery with Smart Contract

Primary LanguageJavaScript

Lottery Basic D-App base on Ethereum smart contract with React, Solidity

Main Idea

Organizer (Owner of contract)

  • Create and manage Store Contract & Ticket NFT Contract
  • Set result for Lottery per times
  • Mint Token for Players
  • Receive 1% Ticket Price when a Player buy a ticket

Players (Who buy Tickets)

  • Buy ticket with pre-set Ticket price
  • Receive prize equal to Total Prize devide Winner Count
  • One player can only buy one Ticket per Ticket times
  • Can manage all their Ticket NFT Tokens
  • You can find your Tokens on OpenSea image

Read more details in contracts

How to run

Git clone this repository

Meta Mask

Web app based on Store contract at address "0xb192E16EE4f6461D216EE6537f5369ab8bcC6F92" on Rinkeby Testnet and "0x05364c26226fe2246aFB5B13e800296bACdaE3e0 " on BSC Testnet

ReactJS Web app

  • Install NodeJS
  • Go to web app folder
  • Then run these commands in terminal/shell
    npm install
    npm start

App will run on BSC testnet by default. Change contract address in lottery.js file to match your net.

Contracts

To deploy your own contracts

  • Go to smartcontract folder
  • Modify file truffle-config.js to match your network
  • Then run this command in terminal/shell
    truffle migrate --network your-network-name
  • Modify contract address in lottery.js file in webapp folder to match your contract
  • Start Web app

To test contracts

  • Install and open Ganache for a local Ethereum network
  • Go to smartcontract folder
  • Then run this command in terminal/shell
    truffle test

Main Features

  • Buy ticket image

  • Manage last time winners image

  • Manage all players this time image

  • Manage all your ticket token image

  • Withdraw image