-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample19.sol
More file actions
34 lines (27 loc) · 897 Bytes
/
example19.sol
File metadata and controls
34 lines (27 loc) · 897 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
pragma solidity 0.4.21;
contract Dao {
mapping(address => bool) public authorized;
address public owner;
constructor() public {
owner = msg.sender;
}
// allows an authorized account to withdraw 1 ETH
function withdraw() public {
if(authorized[msg.sender] && address(this).balance >= 1 ether) {
msg.sender.call.value(1 ether)();
}
authorized[msg.sender] = false;
}
// authorizes an account to withdraw 1 ETH
function authorize(address who) public {
require(msg.sender == owner);
authorized[who] = true;
}
// so that this can accept ether
function() public payable {
}
// auxilliary method for reading the balance
function getBalance() public view returns (uint256) {
return address(this).balance;
}
}