Solidity: examples/safe-remote.rst error

Created on 31 Oct 2019  路  9Comments  路  Source: ethereum/solidity

hi, in this project, I found there is an error in the solidity/docs/examples/safe-remote.rst file, count from bottom to top the second row:
buyer.transfer(value);
should be like this:
buyer.transfer(msg.value);
because at the top of the file, you have already valued the value as msg.value/2.

/// Confirm that you (the buyer) received the item.
    /// This will release the locked ether.
    function confirmReceived()
        public
        onlyBuyer
        inState(State.Locked)
    {
        emit ItemReceived();
        // It is important to change the state first because
        // otherwise, the contracts called using `send` below
        // can call in again here.
        state = State.Inactive;
        // NOTE: This actually allows both the buyer and the seller to
        // block the refund - the withdraw pattern should be used.
        buyer.transfer(value);
        seller.transfer(address(this).balance);
    }

Is it right?

documentation

All 9 comments

@chenzuoli Thanks for the report. I think you are right, with a minor modification: it should be value * 2 and not msg.value since confirmReceived is just a purchase confirmation and not the actual purchase (i.e., msg.value for confirmReceived should be zero).

@ChrisChinchilla I'm tagging this as docs. If you think this is incorrect, please let me know. Also, an ack of what I said/correction would be useful here :-)

@chenzuoli I noticed that you closed the issue, we usually keep the issue open until it is resolved. I'm reopening it for now.

ok, sorry I don't know that.

@chenzuoli would you like to work on a PR to fix this?

Hi, I don't know what is PR, can you tell me something about it? or you can help me fix this problem. thanks.

@chenzuoli No problem, a PR is essentially a proposal for change. I'll create a PR for this issue.

@chenzuoli actually, the original code is correct.

Seller and buyer "stake" 2x the value of item on sale
Once the purchase is made and delivery of item confirmed, the seller obtains value, and buyer loses value

Here's a blog post I found useful in understanding the economics of escrow: https://jacksonng.org/Safe-Remote-Purchase-1

Yeah, get it, I really appreciate you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chriseth picture chriseth  路  3Comments

area picture area  路  3Comments

VoR0220 picture VoR0220  路  4Comments

walter-weinmann picture walter-weinmann  路  4Comments

chriseth picture chriseth  路  4Comments