Skip to content

MatricksDeCoder/Raffle_Dapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Dapp University Simple Blockchain Raffle Ticket Lottery Decentralized Application to run raffles that makes use of Verifiable Random Function (VRF) from Chainlink for reliable fair random numbers. A single ticket is chosen as the winner and receives all the funds in the pool at the end of the raffle/lottery.

Anyone who has been a particiapant in lottery can be able to complete the raffle for a fee, so winner can be paid and raffle resets to allo new one to start play; this avoids the need to have an admin which can be a central point of failure, control, abuse, censorship, manipulation etc. Deployer can earn a percentage fee from the dapp as long as it runs.Blockchain Lotteries ensure fairness, transparency, censorship resistance and more.

Project is for learning and exploration purposes so better UI, and or logic can be created or extended.

Read more about getting random number from Chainlink here

Technology Stack and Tools

Folder / Directory Structure (key folders)
  • raffle_lottery_dapp
    • migrations
    • node_modules
    • public
    • src
      • abis
      • components
      • contracts index.js
    • test

Machine set up (Optional if you have not setup before or having challenges on your system)

  1. Mac & Linux
  • Have python 2.7 installed Check if installed using command below
python -V

If not installed download from python Python Download version 2.7 related to your system

  • Download Ganache Graphical User Interface (GUI ) from Truffle Framework Site choose related to your system

  • Have node-gyp installed Check if installed using command below

If not installed, install using command below

npm i -g node-gyp
  1. Windows machine

Ignore Step 7 in the document below (document for bootcamp setup but applies to setup ubuntu environment)

Machine set up (Optional if you have not setup before or having challenges on your system)

  1. Mac & Linux
  • Have python 2.7 installed Check if installed using command below
python -V

If not installed download from python Python Download version 2.7 related to your system

  • Download Ganache Graphical User Interface (GUI ) from Truffle Framework Site choose related to your system

  • Have node-gyp installed Check if installed using command below

If not installed, install using command below

npm i -g node-gyp
  1. Windows machine

Ignore Step 7 in the document below (document for bootcamp setup but applies to setup ubuntu environment)

Preconfiguration, Installation and Running project locally

  1. You will need nvm if not laready installed; so you can use specific version node version 14 and above
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
$ source ~/.nvm/nvm.sh

Restart your terminal

  1. Install node v14.16.0 or versions above
$ nvm install 14.16.0 
$ nvm alias default 14.16.0 
$ nvm use default
  1. Install truffle globally if not installed. Check if installed using
truffle version

If not installed install with below

$ npm install -g truffle
  1. Ignore if either installed already! To fork need to use use ganache-cli vs Ganache GUI, install ganache-cli globally. Note that ganache-cli rus on port 8545 and ganache-gui runs on port 7545 as placced in truffle-config.js. Check if ganache-cli installed first with
ganache-cli --version

If not installed install with below

$ npm install -g ganache-cli

Run ganache-cli fork of the ethereum mainnet in different terminal and keep running when compiling,testing, migrating, running app etc. Replace account with account with a lot of ETH and LINK e.g 0xbe6977e08d4479c0a6777539ae0e8fa27be4e9d6 See here Make sure unlocked account is the same account in the test file when testing tests/Test.js

ganache-cli -f https://mainnet.infura.io/v3/968a6207d32c4262ae008b7b55d0255e --unlock <account>
  1. Install yarn if not installed. Check if installed using
yarn --version

If not installed install with below

$ npm install --global yarn

Add packages

yarn install
  1. Duplicate the .env.example file and rename it .env. Populate your environment variables .env see .env.example with your infura Id and your privateKey from Metamask account to do deployment e.g first account.

Migrating contracts and Testing Locally to Local Ethereum using Ganache

Make sure deployed Raffle-Dapp Contract always has enough LINK for transactions

  1. Compile,test, Local Ganache Mainnet Fork Ensure ganache is running in seperate terminal.
  • If using Ganache CLI
$ truffle compile
$ truffle test --network development

Testing of front_end app will be done on Kovan network

Migrating contracts Ethereum Kovan Network

Get Kovan ETH into a Metamask account from this Kovan faucet click here or Other Kovan Faucet Click Here. Copy your Metamask address into site and click "Send Me 0.1 Test ETH"

  • Migrate
truffle migrate --network kovan

You can verify deployment, check transactions etc on https://kovan.etherscan.io/ copy the contract address and got to Chainlink Kovan Faucet Enter the contract address and request Test Link and Kovan ETH for account. Read more here from Chainlink about how to fund your contract

yarn start

Connect Metamask to Kovan network

Migrating contracts to Ethereum Mainnet Network

You need to have real value ETH in deploying account in Metamask.

  • Migrate
truffle migrate --network mainnet

View on Mainnet Scan here

  • Run app locally
yarn start

Optional publish front end to Surge

  1. Run build and enter build directory
$ yarn run build
$ cd build
  1. Install surge globally:
$ npm i -g surge

"You may need to Login to surge and create account with email address and a password first time.
If you forgot password you can ask for reset on terminal and get password reset link in your email." Select a unique domain name for your project e.g .surge.sh e.g asdfjkl.surge.sh where my name of choice is asdfjkl

  1. Deploy to surge.
$ surge --domain asdfjkl.surge.sh

...and follow the instructions

Project enhancements and ideas

  • UI/UX + leaner smart contract
  • reduce number reloads or calls to blockchain and change only parts that need changing
  • (who funds LINK with no admin, what is incentive) e.g any sender of LINK to contract when it runs out of LINK can earn fees
  • more winners e.g person with most tickets in raffle gets a share of winnings etc
  • assess for security and vulnerabilities

About

A simple Solidity raffle lottery decentralized app uisng Chainlink VRF and incentivises calling functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors