myhendry / lottery

Demo Lottery using Hardhat Deploy and Typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ethereum Lottery

Overview

This project is a blockchain-based lottery which allows users to enter by paying the entry fee of $50 USD. The winner is determined by obtaining a verifiably random number from a Chainlink oracle, and paying out the contract balance to the corresponding user. The purpose of this project is to gain experience with powerful tools such as Hardhat, Chainlink and OpenZeppelin.

Setup

  1. Clone the repository
  2. Run npm install
  3. Create a secrets.json file with the following contents:
    {
        "alchemyMainnetUrl": "",
        "alchemyRinkebyUrl": "",
        "rinkebySecretKey": ""
    }

Deploying locally

  1. Open a terminal window and run npx hardhat node
  2. Open a second terminal window
  3. Run npx hardhat run scripts/deploy.js --network localhost
  4. Note the addresses of the Lottery and LinkToken contracts

Testing

  • Unit test: run npx hardhat test
  • Integration test: run npx hardhat run test/test_lottery_integration --network rinkeby

Tasks

  1. Run npx hardhat startLottery <Lottery address> --network localhost
  2. Run npx hardhat enterLottery <Lottery address> --network localhost
  3. Run npx hardhat fundWithLink <Lottery address> <LinkToken address> --network localhost
  4. Run npx hardhat endLottery <Lottery address> --network localhost

npx hardhat deploy --network localhost // localhost npx hardhat deploy --network hardhat // hardhat npx hardhat deploy --network rinkeby // rinkeby

npx hardhat test --network localhost // localhost npx hardhat test --network hardhat // hardhat npx hardhat test --network rinkeby // rinkeby

TROUBLESHOOT

Could not resolve dependency DeborahK/Angular-GettingStarted#143 dethcrypto/TypeChain#406

npm outdated npm i --force

About

Demo Lottery using Hardhat Deploy and Typescript


Languages

Language:TypeScript 98.2%Language:Solidity 1.8%Language:Shell 0.0%