diff options
author | chriseth <c@ethdev.com> | 2016-09-05 22:29:08 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-09-07 01:11:41 +0800 |
commit | 4f5a95d569408e6a0a94c54b1eb39ea62b873c5e (patch) | |
tree | e0624ae19d837fb8e2acf9f828c4464e9e788c60 /docs/solidity-by-example.rst | |
parent | fbe0edb32c973166efbd5c0ac556f37fd38584d6 (diff) | |
download | dexon-solidity-4f5a95d569408e6a0a94c54b1eb39ea62b873c5e.tar.gz dexon-solidity-4f5a95d569408e6a0a94c54b1eb39ea62b873c5e.tar.zst dexon-solidity-4f5a95d569408e6a0a94c54b1eb39ea62b873c5e.zip |
Update documentation to version 0.4.0.
Diffstat (limited to 'docs/solidity-by-example.rst')
-rw-r--r-- | docs/solidity-by-example.rst | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index 1eefa4d4..9d3dd6f6 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -255,10 +255,12 @@ activate themselves. /// together with this transaction. /// The value will only be refunded if the /// auction is not won. - function bid() { + function bid() payable { // No arguments are necessary, all // information is already part of - // the transaction. + // the transaction. The keyword payable + // is required for the function to + // be able to receive Ether. if (now > auctionStart + biddingTime) { // Revert the call if the bidding // period is over. @@ -330,16 +332,6 @@ activate themselves. if (!beneficiary.send(highestBid)) throw; } - - function () { - // This function gets executed if a - // transaction with invalid data is sent to - // the contract or just ether without data. - // We revert the send so that no-one - // accidentally loses money when using the - // contract. - throw; - } } Blind Auction @@ -433,6 +425,7 @@ high or low invalid bids. /// still make the required deposit. The same address can /// place multiple bids. function bid(bytes32 _blindedBid) + payable onlyBefore(biddingEnd) { bids[msg.sender].push(Bid({ @@ -535,10 +528,6 @@ high or low invalid bids. if (!beneficiary.send(this.balance)) throw; } - - function () { - throw; - } } .. index:: purchase, remote purchase, escrow @@ -558,7 +547,7 @@ Safe Remote Purchase enum State { Created, Locked, Inactive } State public state; - function Purchase() { + function Purchase() payable { seller = msg.sender; value = msg.value / 2; if (2 * value != msg.value) throw; @@ -566,22 +555,22 @@ Safe Remote Purchase modifier require(bool _condition) { if (!_condition) throw; - _ + _; } modifier onlyBuyer() { if (msg.sender != buyer) throw; - _ + _; } modifier onlySeller() { if (msg.sender != seller) throw; - _ + _; } modifier inState(State _state) { if (state != _state) throw; - _ + _; } event aborted(); @@ -608,6 +597,7 @@ Safe Remote Purchase function confirmPurchase() inState(State.Created) require(msg.value == 2 * value) + payable { purchaseConfirmed(); buyer = msg.sender; @@ -630,10 +620,6 @@ Safe Remote Purchase if (!buyer.send(value) || !seller.send(this.balance)) throw; } - - function() { - throw; - } } ******************** |