This repository is intended to be the code base for the tutorial: https://dev.to/johbu/creating-a-lottery-with-hardhat-and-chainlink-385f
- Clone the repository
git clone https://github.com/johburn/crypto-lottery
- Install dependencies
cd smartcontract
yarn install
- Deploy the smart contract:
yarn run deploy:local
- Run Tests:
yarn run test:unit
- Clone the repository
git clone https://github.com/johburn/crypto-lottery
- Install dependencies
cd ../smartcontract
yarn install
- Copy .env.example into a .env and replace the values
cp .env.example .env
- Deploy the smart contract:
yarn run deploy:testnet
- Transfer some LINK to your wallet
go to https://faucets.chain.link/rinkeby
- Fund your contract:
npx hardhat fund-link --contract <contract address> --fundamount 2000000000000000000 --network rinkeby
- Run Tests:
yarn run test:integration
- Clone the repository
git clone https://github.com/johburn/crypto-lottery
- Install Smart Contract dependencies
cd ../smartcontract
yarn install
- Copy .env.example into a .env and replace the values
cp .env.example .env
- Deploy the smart contract:
yarn run deploy:testnet
- Transfer some LINK to your wallet
go to https://faucets.chain.link/rinkeby
- Fund your contract:
npx hardhat fund-link --contract <contract address> --fundamount 2000000000000000000 --network rinkeby
- Create a Lottery
npx hardhat create --contract <contract address> --seconds 600 --price 0.1 --network rinkeby
- Install backend dependencies:
cd ../backend
yarn install
- Create the database:
psql -f setup/scripts.sql
- Copy .env.example into a .env and replace the values
cp .env.example .env
- Copy contracts json to the backend:
\cp ../smartcontract/deployments/rinkeby/LotteryGame.json ../backend/src/contracts
- Start the backend
yarn run start
- Copy contracts json to the client:
\cp ../smartcontract/deployments/rinkeby/LotteryGame.json ../client/src/contracts
- Start Vite App
yarn run dev
- Participate
Go to localhost 3000 and click on the participate button
- Declare the winner
npx hardhat declare-winner --contract <contract address> --lotteryid <lottery id> --network rinkeby