-
Notifications
You must be signed in to change notification settings - Fork 0
RodgersChayuga/the-lottery-smart-contract
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
THE LOTTERY SMART CONTRACT This code defines a simple lottery smart contract with some security concerns. Here's a breakdown: 1. Setting Up the Lottery: Defines an array players to store participants' addresses (payable for potential transfers). Stores the manager's address (manager) who deployed the contract. 2. Entering the Lottery: The receive function is a fallback function that activates when someone sends Ether to the contract. Requires an exact amount of 0.1 Ether to enter the lottery. Adds the sender's address to the players array. 3. Checking Balance: The getBalance function retrieves the contract's balance in wei. Only the manager can call this function to prevent unauthorized access. 4. Picking a Winner (Unsecure): The pickWinner function allows the manager to select a winner. Requires at least 3 players and ensures only the manager calls it. Uses an insecure random number generation method (random) based on block data, which miners could potentially manipulate. Selects a random index from the players array and assigns the corresponding address as the winner. Transfers the entire contract's balance to the winner's address. Resets the players array for a new round. Security Concerns: Insecure Randomness: The random function uses easily predictable data, making it vulnerable to manipulation by miners who could potentially choose themselves as winners. A secure alternative like Chainlink VRF is recommended. Manager Control: The manager has complete control over picking a winner and can potentially choose themselves or exclude participants. Overall, this is a basic lottery contract but lacks security measures for fair and random winner selection.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published