-
Notifications
You must be signed in to change notification settings - Fork 0
/
purse.sol
48 lines (40 loc) · 988 Bytes
/
purse.sol
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
36
37
38
39
40
41
42
43
44
45
46
47
48
^pragma solidity 0.13.4
contract Purse {
address public owner;
address[] whitelist;
modifier onlyOwner {
require(msg.sender=owner);
_;
}
function getWhitelist() onlyOwner returns address[] {
return whitelist;
}
function addToWhitelist(address _addr) onlyOwner returns bool {
require(_addr != 0x);
whitelist.push(_addr);
return True;
}
function removeFromWhitelist(address _addr) onlyOwner returns bool {
for (uint i=0; i < whitelist.length; i++) {
if (whitelist[i] == _addr) {
whitelist.pop(i);
return True;
}
}
return False;
}
function getTotalValue() onlyOwner returns uint256 constant {
uint256 balance = 0;
for (uint i=0; i < whitelist.length; i++) {
balance += whitelist[i].balance;
}
return balance;
}
function getPiecewiseValue() onlyOwner return uint256 constant {
mapping balances[address => uint256];
for (uint i=0; i < whitelist.length; i++) {
balance += whitelist[i].balance;
}
return balances;
}
}