Skip to content

paulsimroth/foundry-lottery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foundry Lottery with proofable randomness

Objective

This is a proofably random smart contract lottery built with foundry. This project is a smart contract lottery using Chainlink VRF to determine a random winner. Chainlink automation is used to call the functions to determine the winner. This project does also include the relevant tests.

  1. Users can enter by purchasing a ticket
  2. After a specific time period the lottery will draw a winner
  3. This will be done with ChainLink Automation (Time based trigger) and VRF (verifiable randomness)
  4. The winner will receive all ticket fees gathered.

Tech Stack

Usage

Project Setup

If you want to clone this project run the following command

$ forge init
$ make install

Build and Compile Contracts

$ forge build

Test

$ forge test 

Run test with matching function

$ forge test --match-test <testYourTestName>

Test how much of your contracts your test cover by running this command:

$ forge coverage

get more inforamtion on what functions still need to be tested and output it to coverage.txt

$ forge coverage --report debug > coverage.txt

Debug tool; With this you can navigate throught your contract opcode

$ forge test --debug <testYourTestName>

Gas Estimation

You can estimate how much gas things cost by running:

$ forge snapshot

Anvil (Fooundry Local Dev Chain)

$ anvil

Deploy

$ forge script script/DeployRaffle.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key>

or use the commands in the makefile

deploy to local Anvil chain

here make sure to start up Anvil before running this command

$ make deploy

deploy to Sepolia Testnet

$ make deploy ARGS="--network sepolia"

NOTE FOR DEPLOYMENT

After deploying the contract you must manually register a new Upkeep on Chainlink Automation using the contract address!

Cast

You can interact with your contracts from the command line useing cast

$ cast <subcommand>

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published