Giter Club home page Giter Club logo

foundry-lottery's Introduction

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>

foundry-lottery's People

Contributors

paulsimroth avatar

Watchers

 avatar  avatar

Forkers

dashbaord202401

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.