Coder Social home page Coder Social logo

lottery's Introduction

♠ Lottery ♣

Lottery contract with VRF2 Contract is using VRFv2 for generating random numbers. Therefore, for the correct operation of the contract, it is necessary to create subscription on > https://vrf.chain.link/goerli for rinkeby testnet or https://vrf.chain.link/mainnet for mainnet, replenish the balance of LINK and add contract address as a consumer

📁 Table of Contents

🚩 General Information

  • Owner(admin) of the contract can start/end lottery
  • Every user can participate and price of ticket is based on LOT ERC20 tokens. Each ticket represents itself an ERC721 token
  • After owner end lottery, the winner will be picked using randomness from Chainlink VRFv2 Coordinator

💻 Technologies Used

  • Chainlink VRFv2
  • hh coverage
  • slither
  • docgen

🌟 Features

  • Trully random contract(Ideally for lottery)
  • Ticket price is based LOT tokens
  • The contract has been properly reviewed.

👀 Requirements For Initial Setup

  • Install NodeJS, should work with any node version below 16.16.0
  • Install Hardhat

📟 Setup

1. 💾 Clone/Download the Repository

2. 📦 Install Dependencies:

$ cd lottery_file
$ npm install

3. 🔍 .env environment variables required to set up

Create .env file inside project folder

  • You can get your ethereum or testnet API key here,here or any other service that allow you to connect to the nodes
  • You can get your private key from your wallet (Don't share your private key with untrusted parties)
  • Subscription id can be obtained here after creation of subscription here
  • Key Hash and address of vrf coordinator can be obtained from here here Just choose network and copy:)
  • You can get your etherscan API -key here.
  • LOT_ADDRESS be available after deploying contracts
GOERLI_API = <Goerli API key>
MAINNET_API = <Ethereum mainnet API key>
PRIVATE_KEY = <Private key of your wallet u want to deploy contracts from>
ETHERSCAN_KEY = <Etherscan API key in order to verify your contracts>
SUBSCRIPTION_ID = <VRFv2 subcription id>
KEY_HASH = <Key Hash>
AGGREGATOR = <Aggregator address(depends on network)>
VRF_COORDINATOR = <VRF coordinator address(depends on network)>
PERCENT_WINNER = <Percent of total collected funds of lottery winner will receive(PERCENT_WINNER+PERCENT_OWNER must be 100)>
PERCENT_OWNER = <Percent of total collected funds of lottery winner will receive(PERCENT_WINNER+PERCENT_OWNER must be 100)>
TICKET_PRICE = <Price in LOT tokens in order to participate in Lottery>

4. ⚠️ Run Tests

$ npm run test
$ npm run coverage

5. 🚀 Deploy to GORELI or Mainnet

$ npm run deploy:goerli
$ npm run deploy:polygon
$ npm run deploy:mainnet

Note:

deploy.ts implements the verification script and you don't need to complete any additional steps in order to verify the contract.

💬 Contact

Created by @LESKOV - feel free to contact me!

lottery's People

Contributors

ileskov 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.