https://github.com/ankitkataria/lottery-dapp
:moneybag: A block-chain based Lottery System
https://github.com/ankitkataria/lottery-dapp
blockchain ethereum truffle-framework
Last synced: about 1 year ago
JSON representation
:moneybag: A block-chain based Lottery System
- Host: GitHub
- URL: https://github.com/ankitkataria/lottery-dapp
- Owner: ankitkataria
- Created: 2018-04-01T23:49:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-29T15:19:23.000Z (over 7 years ago)
- Last Synced: 2025-03-27T06:44:52.670Z (over 1 year ago)
- Topics: blockchain, ethereum, truffle-framework
- Language: JavaScript
- Homepage:
- Size: 314 KB
- Stars: 40
- Watchers: 3
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lottery DApp
> A block-chain based Lottery System made using [Truffle](truffleframework.com)
### 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 git@github.com:ankitkataria/Lottery-DApp.git`
- Change directory to cloned copy and run: `npm install`
- Install truffle: `npm install -g truffle`
- Download [Ganache](http://localhost:9000/ganache/) AppImage
- Run ganache AppImage

- 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


### Todo
- [ ] Add current lottery state to local storage
- [ ] Add functionality to reimburse tokens once game is closed
### References
- [Ethereum White Paper](https://github.com/ethereum/wiki/wiki/White-Paper)
- [Truffle Docs](truffleframework.com/docs/)
- [CrypotZombies](https://cryptozombies.io/)
- [Bitcoin Paper](https://bitcoin.com/bitcoin.pdf)