Last active
July 4, 2016 10:14
-
-
Save gotoalberto-zz/05bb74d1a7301644ac3959459ac1292a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract salary { | |
| address owner = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; | |
| uint256 fee = 1000000; | |
| mapping (uint256 => address) private employees; | |
| function Pay() onlyOwner { | |
| if (ThereAreSufficientFunds) PayAllEmployees(); | |
| } | |
| function GetBackFunds() onlyOwner { | |
| msg.sender.send(this.balance); | |
| } | |
| function PayAllEmployees onlyOwner private returns(bool) { | |
| for (var i = employees.iterate_start(); employees.iterate_valid(i); i = employees.iterate_next(i)) | |
| uint256 salary = employees.iterate_get(i).value | |
| address employee = employees.iterate_get(i).key | |
| employee.send(salary) | |
| } | |
| } | |
| function ThereAreSufficientFunds() onlyOwner private returns(bool) { | |
| uint256 totalPayment = 0; | |
| for (var i = employees.iterate_start(); employees.iterate_valid(i); i = employees.iterate_next(i)) | |
| totalPayment += employees.iterate_get(i).value; | |
| totalPayment += fee | |
| } | |
| (this.balance < totalPayment) | |
| } | |
| function NewSalary(address employee, uint256 salary) { | |
| employees[employee] = salary; | |
| } | |
| modifier onlyOwner { | |
| if(msg.sender != owner) throw; | |
| _ | |
| } | |
| function () { | |
| throw; | |
| } | |
| msg.sender.send(msg.value); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment