The Lottery
contract allows participants to join a lottery by contributing a specific amount of Ether. The lottery is managed by a designated manager who can pick a winner and distribute the prize.
Interact with this contract via Etherscan using the contract address "0x1F65312E129DBeBe306163210D170248a0F8b85b" in the Seploia Test Net.
- Contract Name: Lottery
- Solidity Version: ^0.7.0
- License: MIT
- Type: Array
- Value Type: address payable
An array that stores the addresses of all participants who joined the lottery by contributing Ether.
- Type: address payable
The address of the winner who is randomly picked by the manager.
- Type: address payable
The address of the manager who oversees the lottery and performs administrative functions.
- Type: uint256
The total amount of Ether accumulated from the participants' contributions.
- Type: bool
A boolean flag indicating whether the lottery is currently open for participation.
A modifier that restricts access to functions only to the manager of the lottery.
- Parameters: None
- Payable: Yes
Allows a participant to join the lottery by sending 1 ETH as payment. The participant's address is added to the players
array, and the totalFunds
variable is incremented.
- Parameters: None
Randomly selects a winner from the players
array and transfers the majority (80%) of the totalFunds to the winner's address. The remaining funds are transferred to the manager. After picking a winner, the players
array is reset, and the totalFunds
variable is set to zero. The lottery is then closed.
- Parameters: None
- Returns: uint256
Returns the current balance of the lottery contract.
- Parameters: None
- Returns: address payable[]
Returns an array of addresses representing the participants who joined the lottery.
- Parameters: None
- Returns: address
Returns the address of the manager overseeing the lottery.
- Parameters: None
- Returns: address payable
Returns the address of the winner of the lottery.
- Parameters: None
Closes the lottery and destroys the contract, transferring any remaining funds to the manager's address. Only the manager can call this function.
- Parameters: None
Reopens the lottery for participation. Only the manager can call this function.