-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample6.sol
More file actions
35 lines (29 loc) · 1.05 KB
/
example6.sol
File metadata and controls
35 lines (29 loc) · 1.05 KB
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
pragma solidity ^0.4.21;
contract MyAugmented {
mapping(address => uint) balances;
mapping(address => bool) winners;
uint gameReward = 50;
function deposit() payable{
balances[msg.sender] += msg.value;
}
// function withdrawFunds (uint256 _weiToWithdraw) public {
// require(balances[msg.sender] >= _weiToWithdraw);
// (bool success,) = msg.sender.call.value(_weiToWithdraw)("");
// require(success);
// balances[msg.sender] -= _weiToWithdraw;
// }
function safeWithdrawFunds(uint256 amount) public {
require(balances[msg.sender] >= amount);
balances[msg.sender] -= amount;
(bool success,) = msg.sender.call.value(amount)("");
require(success);
}
function claimReward() public {
bool isWinner = winners[msg.sender];
require(isWinner);
bool hasMoney = balances[msg.sender] > 5;
require(hasMoney);
require(msg.sender.call.value(gameReward)());
winners[msg.sender] = false;
}
}