Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pragma solidity ^0.4.23;
contract Splitter {
address sender;
address public receiver1;
address public receiver2;
event AmountTransferred(address owner, uint amount);
constructor(address _sender,address _receiver1, address _receiver2) public{
sender = _sender;
receiver1 = _receiver1;
receiver2 = _receiver2;
}
modifier amountGreaterThanOne() {
require(msg.value > 1);
_;
}
modifier onlySender() {
require(msg.sender == sender);
_;
}
function getreceiver1Balance() public view returns (uint) {
return receiver1.balance;
}
function getreceiver2Balance() public view returns (uint) {
return receiver2.balance;
}
function payReceivers() payable public onlySender amountGreaterThanOne {
uint amount = msg.value/2;
receiver1.transfer(amount);
emit AmountTransferred(receiver1,amount);
receiver2.transfer(amount);
emit AmountTransferred(receiver2,amount);
}
}
@rob-Hitchens

This comment has been minimized.

Copy link

@rob-Hitchens rob-Hitchens commented Apr 27, 2018

Line 26 & 30 ... these functions that return <address>balance don't do anything useful because everyone everywhere can check can check anyone's balance without our help. You will see something very similar in the actual solution that solves for DoS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment