-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxHand.sol
More file actions
35 lines (27 loc) · 903 Bytes
/
BoxHand.sol
File metadata and controls
35 lines (27 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
contract BoxHand {
address[] public s_participants;
mapping(address => uint256) public s_addressToAmountFunded;
uint256 public i_entranceFee;
address public i_owner;
constructor(uint256 _entranceFee) {
i_entranceFee = _entranceFee;
i_owner = msg.sender;
}
function contribute() public payable {
require(msg.value > 0 , "Need more than ZERO!");
s_participants.push(msg.sender);
s_addressToAmountFunded[msg.sender] += msg.value;
}
modifier onlyOwner {
require(msg.sender == i_owner, "Sender is not owner!");
_;
}
function payout(address payable _winner) public onlyOwner {
uint256 totalPot = address(this).balance;
(bool success, ) = _winner.call{value: totalPot}("");
require(success, "Transfer failed");
}
}