Skip to content

Repository files navigation

Foundry Raffle

A decentralized raffle smart contract using Chainlink VRF for provably fair random winner selection and Chainlink Automation for automated execution

Overview

Automated lottery system that-

  • Accepts entries via entrance fee
  • Automatically selects random winner using Chainlink VRF
  • Distributes entire contract balance to winner
  • Uses Chainlink Keepers to trigger winner selection at intervals

States: OPEN (accepting entries) → CALCULATING (selecting winner)

Prerequisites

Contract Functions

Main Functions:

  • enterRaffle() - Enter raffle (pay entrance fee)
  • checkUpkeep() - Check if upkeep needed (Chainlink Keepers)
  • performUpkeep() - Trigger VRF request
  • fulfillRandomWords() - VRF callback (selects winner)

Getters: getRaffleState(), getRecentWinner(), getNumberOfPlayers(), getEntranceFee(), etc.

Events: RaffleEnter, RequestedRaffleWinner, WinnerPicked

Project Structure

src/Raffle.sol                 # Main contract
script/DeployRaffle.s.sol      # Deployment script
script/HelperConfig.s.sol      # Network config
test/unit/RaffleTest.t.sol     # Unit tests
test/integration/              # Integration tests

Documentation

License

MIT

Author

Ohburmaa

About

Decentralized Raffle smart contract built with Solidity, Foundry, and Chainlink VRF. Fully tested with unit, integration, and mock-based randomness

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages