Verified contractPartial
FourWaySplit
Address0x8e0600987cb75d2da6871b5d970f004ed1f2cb8d
- Balance
0 ETH
- Transactions
14
- Compiler
solc 0.4.11
- Same code
Only this contract
Details
- Compiler
- solc 0.4.11+commit.68ef5810
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 3,871,910
- Creation transaction
- 0x2f03a13a41…eaca241693
FourWaySplit.sol
pragma solidity ^0.4.6;
contract FourWaySplit {
// balances and account list are publicly visible
mapping(address => uint) public beneficiaryBalance;
address[4] public beneficiaryList;
// emit events for real-time listeners and state history
event LogReceived(address sender, uint amount);
event LogWithdrawal(address beneficiary, uint amount);
// give the constructor four addresses for the split
function FourWaySplit(address addressA, address addressB, address addressC, address addressD) {
beneficiaryList[0]=addressA;
beneficiaryList[1]=addressB;
beneficiaryList[2]=addressC;
beneficiaryList[3]=addressD;
}
// send ETH
function pay()
public
payable
returns(bool success)
{
if(msg.value==0) throw;
// ignoring values not evenly divisible by 4. We round down and keep the change.
// (No way to remove the loose change, so it's effectively destroyed.)
uint forth = msg.value / 4;
beneficiaryBalance[beneficiaryList[0]] += forth;
beneficiaryBalance[beneficiaryList[1]] += forth;
beneficiaryBalance[beneficiaryList[2]] += forth;
beneficiaryBalance[beneficiaryList[3]] += forth;
LogReceived(msg.sender, msg.value);
return true;
}
function withdraw(uint amount)
public
returns(bool success)
{
if(beneficiaryBalance[msg.sender] < amount) throw; // insufficient funds
beneficiaryBalance[msg.sender] -= amount; // Optimistic accounting.
if(!msg.sender.send(amount)) throw; // failed to transfer funds
LogWithdrawal(msg.sender, amount);
return true;
}
}Compiler settingsShow
{
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.