forked from magonicolas/Ethereum-Solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPayCheck2.sol
More file actions
38 lines (28 loc) · 956 Bytes
/
PayCheck2.sol
File metadata and controls
38 lines (28 loc) · 956 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
36
37
38
pragma solidity ^0.4.0;
contract PayCheck {
address[] employees = [0xE83fad0b5EdF2999c29a00199Ca9B773A4627239, 0xc6A0c2424BF99f3E65799316710448FdE8c2B228];
mapping (address => uint) withdrawnAmounts;
function PayCheck() payable {
}
function () payable {
}
modifier canWithdraw() {
bool contains = false;
for(uint i = 0; i < employees.length; i++) {
if(employees[i] == msg.sender) {
contains = true;
}
}
require(contains);
_;
}
function withdraw() canWithdraw {
uint amountAllocated = this.balance/employees.length;
uint amountWithdrawn = withdrawnAmounts[msg.sender];
uint amount = amountAllocated - amountWithdrawn;
withdrawnAmounts[msg.sender] = amountWithdrawn + amount;
if (amount > 0) {
msg.sender.transfer(amount);
}
}
}