Skip to content

Instantly share code, notes, and snippets.

@Sindbag
Created October 5, 2017 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sindbag/0a11b58cbb4cc46d604e19ed2cf65e5b to your computer and use it in GitHub Desktop.
Save Sindbag/0a11b58cbb4cc46d604e19ed2cf65e5b to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.8;
contract Ballot {
uint256 firstBid;
address firstBidder;
event MoneySend(address winner);
function sendMoney(address winner, uint256 amount) internal {
MoneySend(winner);
winner.send(amount);
}
function set(uint256 currBid) payable {
require(currBid > 0);
if (firstBid > 0) {
if (firstBid > currBid) {
sendMoney(firstBidder, this.balance);
} else if (firstBid < currBid) {
sendMoney(msg.sender, this.balance);
} else {
sendMoney(firstBidder, this.balance / 2);
sendMoney(msg.sender, this.balance / 2);
}
firstBid = 0;
} else {
firstBid = currBid;
firstBidder = msg.sender;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment