Skip to content

laurentknauss/smart-contract-raffle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart contract set-up powering webraffle.xyz

##Decentralized raffle systems powered by Chainlink VRF for randomness.##

General Overview

  • Raffle Contract: A smart contract for creating and managing a raffle where participants enter by sending ETH, and a winner is randomly selected.

Key Features

  • Entry Mechanism:

    • Participants can join the raffle by sending the required entrance fee in ETH.
    • Entry is only valid when the raffle is OPEN.
  • State Management:

    • The contract tracks raffle states (OPEN, CALCULATING) to manage entries and winner selection effectively.
  • Random Winner Selection:

    • Utilizes Chainlink VRF to fetch a verifiable random number for declaring the winner based on player entries.
  • Upkeep Automation:

    • Implements Chainlink Keepers for automatic checks to ensure upkeep conditions (time interval, player count, ETH balance) are met before selecting a winner.
  • Events:

    • Emits critical events for major actions:
      • RaffleEnter for new entries,
      • WinnerPicked for selected winners,
      • RequestedRaffleWinner whenever a random number request is made.

Error Handling

  • Custom Errors:
    • Efficiently handle failures such as:
      • Insufficient funds for entry,
      • Raffle closure,
      • Upkeep not needed,
      • Transfer failures to the winner.

Functionality Highlights

  • Constructor:

    • Initializes essential parameters—subscription ID, gas lane, entrance fee, and other operational details.
  • Functions:

    • Check upkeep conditions,
    • Perform the raffle,
    • Fulfill VRF responses to establish winner payouts and state updates.

Testing and Quality Assurance

  • Implemented with rigorous testing strategies, including:
    • Unit tests,
    • Integration tests, ensuring contract reliability before deployment.
  • Continuous integration practices to catch issues early through automated testing and static analysis.

Performance Optimization

  • Structured for gas efficiency, carefully managing state variables and storage to minimize costs.

Development Workflow

  • Maintain a robust workflow using tools like Foundry for testing, supporting a sustainable path for development and deployment.  

About

smart-contract backend files powering webraffle.xyz

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published