This is a smart contract for a raffle. Participants can buy tickets with native token and have a chance to win a specified ERC721 (NFT) prize.
This is a smart contract for a raffle. Participants can buy tickets with native token and have a chance to win a specified ERC721 (NFT) prize. The contract allows an admin to start and end the lottery, pick a winner, and manage the ticket cost and NFT prize.
startLottery
Starts the lottery by setting the NFT contract address and token ID for the prize. The nftContract parameter represents the address of the NFT contract, and the tokenId parameter represents the token ID of the prize.
endLottery
Ends the lottery and prevents any further ticket purchases.
pickWinner
Randomly selects a winner from the participants and transfers the NFT prize to the winner.
changeTicketCost
Changes the ticket cost to the specified _newCost value. This can only be done when the lottery is not running.
getPlayers
Returns an array of addresses representing the participants who have purchased tickets.
getBalance
Returns the current balance of the contract in Ether.
withdrawBalance
Allows the admin to withdraw the balance of the contract.
The contract emits the following events:
Jul 01, 2023
Apache-2.0, MIT, Unlicense