-
Notifications
You must be signed in to change notification settings - Fork 0
/
TieredProfitSplitter.sol
44 lines (34 loc) · 1.19 KB
/
TieredProfitSplitter.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
pragma solidity ^0.5.0;
// lvl 2: tiered split
contract TieredProfitSplitter {
address payable employee_one; // ceo
address payable employee_two; // cto
address payable employee_three; // King Bob
constructor(address payable _one, address payable _two, address payable _three) public {
employee_one = _one;
employee_two = _two;
employee_three = _three;
}
// Should always return 0! Use this to test your `deposit` function's logic
function balance() public view returns(uint) {
return address(this).balance;
}
function deposit() public payable {
uint points = msg.value / 100; // Calculates rudimentary percentage by dividing msg.value into 100 units
uint total;
uint amount;
amount = points * 5;
total += amount;
employee_one.transfer(amount);
amount = points * 10;
total += amount;
employee_two.transfer(amount);
amount = points * 85;
total += amount;
employee_three.transfer(amount);
employee_one.transfer(msg.value - total); // ceo gets the remaining wei
}
function() external payable {
deposit();
}
}