A Simple Lottery is a basic and straightforward form of a lottery system where participants enter for a chance to win a prize by purchasing a ticket or meeting a participation requirement.
// Reset the players array for the next round
delete players;
}
// Function to get the winner's address
function getWinner() public view returns (address) {
return winner;
}
// Function to get the players count
function getPlayersCount() public view returns (uint) {
return players.length;
}
// Function to withdraw the funds by the winner
function withdraw() public {
// Ensure only the winner can withdraw
require(msg.sender == winner, "Only the winner can withdraw the prize.");
// Transfer the balance of the contract to the winner
payable(winner).transfer(address(this).balance);
}
}
License
This project is licensed under the MIT License.
70
0