Giter Club home page Giter Club logo

lottery-dapp's Introduction

Lottery DApp

A block-chain based Lottery System made using Truffle

Features

  • The owner of the Lottery contract sets a SHA3 hash of the winning guess between 1 and 1'000'000

  • In order to participate a user sends required amount in ETH to the contract and gets 1 participation token per ETH in return

  • The users makes guess using the makeGuess() function of the contract, 1 token is deducted for each guess

  • The Lottery contract has a closeGame() function that the owner can invoke to stop any further guessing

  • The unused tokens are not reimbursed

  • A function winnerAddress() returns the address of the winner once the game is closed

  • Once the game is closed the winner can call getPrice() to collect 50% of the ETH in the contract

  • The getPrice() function sends the remaining 50% of ETH to the owner of the contract

  • The owner receives all the money that contract holds if there are no correct guesses

Setup

  • Clone repo: git clone [email protected]:ankitkataria/Lottery-DApp.git

  • Change directory to cloned copy and run: npm install

  • Install truffle: npm install -g truffle

  • Download Ganache AppImage

  • Run ganache AppImage

ganache

  • Set the winning guess in migrations/2_add_lottery_contract.js

  • Compile truffle contracts: truffle compile

  • Migrate truffle contract to blockchain: truffle migrate

  • Run server: npm run dev

  • Open http://localhost:8080 in browser

dashboard1

dashboard2

Todo

  • Add current lottery state to local storage
  • Add functionality to reimburse tokens once game is closed

References

lottery-dapp's People

Contributors

ankitkataria avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.