This file contains hidden or 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
function withdraw() | |
onlyEndedOrCanceled | |
returns (bool success) | |
{ | |
address withdrawalAccount; | |
uint withdrawalAmount; | |
if (canceled) { | |
// if the auction was canceled, everyone should simply be allowed to withdraw their funds | |
withdrawalAccount = msg.sender; |
This file contains hidden or 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
function cancelAuction() | |
onlyOwner | |
onlyBeforeEnd | |
onlyNotCanceled | |
returns (bool success) | |
{ | |
canceled = true; | |
LogCanceled(); | |
return true; | |
} |
This file contains hidden or 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
// static | |
address public owner; | |
uint public startBlock; | |
uint public endBlock; | |
string public ipfsHash; | |
uint public bidIncrement; | |
// state | |
bool public canceled; | |
address public highestBidder; |
This file contains hidden or 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
function placeBid() | |
payable | |
onlyAfterStart | |
onlyBeforeEnd | |
onlyNotCanceled | |
onlyNotOwner | |
returns (bool success) | |
{ | |
// reject payments of 0 ETH | |
if (msg.value == 0) throw; |
This file contains hidden or 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
modifier onlyNotOwner { | |
if (msg.sender == owner) throw; | |
_; | |
} | |
modifier onlyAfterStart { | |
if (block.number < startBlock) throw; | |
_; | |
} |
This file contains hidden or 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
modifier onlyRunning { | |
if (canceled) throw; | |
if (block.number < startBlock || block.number > endBlock) throw; | |
_; | |
} |
This file contains hidden or 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
function placeBid() | |
onlyAfterStart | |
onlyBeforeEnd | |
onlyNotCanceled | |
onlyNotOwner | |
returns (bool success) | |
{ | |
// ... | |
} |
This file contains hidden or 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
function Auction(address _owner, uint _bidIncrement, uint _startBlock, uint _endBlock, string _ipfsHash) { | |
if (_startBlock >= _endBlock) throw; | |
if (_startBlock < block.number) throw; | |
if (_owner == 0) throw; | |
owner = _owner; | |
bidIncrement = _bidIncrement; | |
startBlock = _startBlock; | |
endBlock = _endBlock; | |
ipfsHash = _ipfsHash; |
This file contains hidden or 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
contract Auction { | |
function placeBid() returns (bool success) {} | |
function withdraw() returns (bool success) {} | |
function cancelAuction() returns (bool success) {} | |
event LogBid(address bidder, uint bid, address highestBidder, uint highestBid, uint highestBindingBid); | |
event LogWithdrawal(address withdrawer, address withdrawalAccount, uint amount); | |
event LogCanceled(); | |
} |
This file contains hidden or 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
contract DavesWallet { | |
event GotSomeMoney(uint amount, uint balance); | |
function() payable { | |
GotSomeMoney(msg.value, this.balance); | |
} | |
} |