/smartcontract-lottery

Users can enter lottery with ETH based on USD fee then an admin will choose when the lottery is over, the lottery will randomly select a winner using VRF

Primary LanguageSolidityMIT LicenseMIT

Smart Contract Lottery Repo

Features:

  1. Users can enter lottery with ETH based on a USD fee
  2. An admin will choose when the lottery is over
  3. The lottery will select a random winner

Prerequisites

Installation

Install Brownie

python3 -m pip install --user pipx
python3 -m pipx ensurepath
# restart your terminal
pipx install eth-brownie

Or

pip install eth-brownie

Testnet Development

Set your WEB3_INFURA_PROJECT_ID by creating a project of Infura, and PRIVATE_KEY environment variables from your ethereum wallet like metamask.

You'll also need testnet rinkeby ETH and LINK. You can get LINK and ETH into your wallet by using the rinkeby faucets located here.

Then add your environment variables to the .env file:

export WEB3_INFURA_PROJECT_ID=<PROJECT_ID>
export PRIVATE_KEY=<PRIVATE_KEY>

AND THEN RUN source .env TO ACTIVATE THE ENV VARIABLES

Local Development

For local testing install ganache-cli

npm install -g ganache-cli

All the scripts are designed to work locally or on a testnet. You can add a ganache-cli or ganache UI chain like so:

brownie networks add Ethereum ganache host=http://localhost:8545 chainid=1337

Deploy to a testnet / Scripts

brownie run scripts/deploy.py

This will deploy mocks on development enviroment (ganache-local) Or deploy on Kovan/Rinkeby testnet:

brownie run scripts/deploy.py --network rinkeby

Testing on local blockchain

brownie test

Or, test on Kovan/Rinkeby testnet:

brownie test --network kovan
brownie test --network rinkeby

Adding additional Chains

brownie networks add Ethereum binance-smart-chain host=https://bsc-dataseed1.binance.org chainid=56

or, for a fork:

brownie networks add development binance-fork cmd=ganache-cli host=http://127.0.0.1 fork=https://bsc-dataseed1.binance.org accounts=10 mnemonic=brownie port=8545

Resources

License

This project is licensed under the MIT license.