This Solidity smart contract implements a lottery system where participants can enter by sending a minimum amount of Ether. The winner is determined randomly using Chainlink's Verifiable Random Function (VRF), ensuring fairness and transparency.
- Allows participants to enter the lottery by sending Ether.
- Determines the winner randomly using Chainlink's VRF.
- Provides a transparent and decentralized method for selecting winners.
- Implements access control to start and end lotteries, with the owner having exclusive control.
- Chainlink VRFConsumerBase - Interface for interacting with Chainlink's VRF.
- OpenZeppelin Ownable - Provides basic access control functions.
- Setup: Deploy the contract with the necessary constructor parameters, including the address of the ETH/USD price feed, VRF coordinator, LINK token address, fee, and keyhash.
- Starting a Lottery: Only the owner can start a new lottery using the
startLottery()
function. - Entering the Lottery: Participants can enter the lottery by sending the required amount of Ether using the
enter()
function. - Ending the Lottery: After participants have entered, the owner can end the lottery and determine the winner using the
endLottery()
function. - Winner Determination: The winner is randomly selected using Chainlink's VRF and announced by the contract.
- Claiming Winnings: The winner can claim their winnings by withdrawing them from the contract.