Skip to content

johburn/crypto-lottery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crypto Lottery

This repository is intended to be the code base for the tutorial: https://dev.to/johbu/creating-a-lottery-with-hardhat-and-chainlink-385f

Test Smart Contract locally

  1. Clone the repository
git clone https://github.com/johburn/crypto-lottery
  1. Install dependencies
cd smartcontract
yarn install
  1. Deploy the smart contract:
yarn run deploy:local
  1. Run Tests:
yarn run test:unit

Test Smart Contract on Testnet

  1. Clone the repository
git clone https://github.com/johburn/crypto-lottery
  1. Install dependencies
cd ../smartcontract
yarn install
  1. Copy .env.example into a .env and replace the values
cp .env.example .env
  1. Deploy the smart contract:
yarn run deploy:testnet
  1. Transfer some LINK to your wallet

go to https://faucets.chain.link/rinkeby

  1. Fund your contract:
npx hardhat fund-link --contract <contract address> --fundamount 2000000000000000000 --network rinkeby
  1. Run Tests:
yarn run test:integration

Test Smart Contract with Vite App and Postgres

  1. Clone the repository
git clone https://github.com/johburn/crypto-lottery
  1. Install Smart Contract dependencies
cd ../smartcontract
yarn install
  1. Copy .env.example into a .env and replace the values
cp .env.example .env
  1. Deploy the smart contract:
yarn run deploy:testnet
  1. Transfer some LINK to your wallet

go to https://faucets.chain.link/rinkeby

  1. Fund your contract:
npx hardhat fund-link --contract <contract address> --fundamount 2000000000000000000 --network rinkeby
  1. Create a Lottery
npx hardhat create --contract <contract address> --seconds 600 --price 0.1 --network rinkeby
  1. Install backend dependencies:
cd ../backend
yarn install
  1. Create the database:
psql -f setup/scripts.sql
  1. Copy .env.example into a .env and replace the values
cp .env.example .env
  1. Copy contracts json to the backend:
\cp ../smartcontract/deployments/rinkeby/LotteryGame.json ../backend/src/contracts
  1. Start the backend
yarn run start
  1. Copy contracts json to the client:
\cp ../smartcontract/deployments/rinkeby/LotteryGame.json ../client/src/contracts
  1. Start Vite App
yarn run dev
  1. Participate

Go to localhost 3000 and click on the participate button

client

  1. Declare the winner
npx hardhat declare-winner --contract <contract address> --lotteryid <lottery id> --network rinkeby

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published