-
-
Save Sindbag/0a11b58cbb4cc46d604e19ed2cf65e5b to your computer and use it in GitHub Desktop.
This file contains 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
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