##Decentralized raffle systems powered by Chainlink VRF for randomness.##
- Raffle Contract: A smart contract for creating and managing a raffle where participants enter by sending ETH, and a winner is randomly selected.
-
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.
- Emits critical events for major actions:
- Custom Errors:
- Efficiently handle failures such as:
- Insufficient funds for entry,
- Raffle closure,
- Upkeep not needed,
- Transfer failures to the winner.
- Efficiently handle failures such as:
-
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.
- 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.
- Structured for gas efficiency, carefully managing state variables and storage to minimize costs.
- Maintain a robust workflow using tools like Foundry for testing, supporting a sustainable path for development and deployment.