Verified contractPartial
Bank
Address0x36770ff967bd05248b1c4c899ffb70caa3391b84
- Balance
0 ETH
- Transactions
37
- Compiler
solc 0.4.18
- Same code
4 more contracts
Details
- Compiler
- solc 0.4.18+commit.9cf6e910
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 4,905,564
- Creation transaction
- 0x4c41fe035e…ce87b75361
Bank.sol
pragma solidity ^0.4.18;
// zeppelin-solidity: 1.5.0
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract Bank {
using SafeMath for *;
uint public totalShares = 0;
uint public totalReleased = 0;
mapping(address => uint) public shares;
mapping(address => uint) public released;
address[] public payees;
function Bank(address[] _payees, uint[] _shares) public payable {
require(_payees.length == _shares.length);
for (uint i = 0; i < _payees.length; i++) {
addPayee(_payees[i], _shares[i]);
}
}
function addPayee(address _payee, uint _shares) internal {
require(_payee != address(0));
require(_shares > 0);
require(shares[_payee] == 0);
payees.push(_payee);
shares[_payee] = _shares;
totalShares = totalShares.add(_shares);
}
function claim() public {
address payee = msg.sender;
require(shares[payee] > 0);
uint totalReceived = this.balance.add(totalReleased);
uint payment = totalReceived.mul(shares[payee]).div(totalShares).sub(released[payee]);
require(payment != 0);
require(this.balance >= payment);
released[payee] = released[payee].add(payment);
totalReleased = totalReleased.add(payment);
payee.transfer(payment);
}
function () public payable {}
}Compiler settingsShow
{
"optimizer": {
"runs": 0,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.