I’m looking to build a simple store dapp where users can buy products with Ether and I came across this Safe Remote Purchase contract in the Solidity docs and I am looking for some further explanation in how this contract works.
My understanding is that a seller must deposit twice the amount of Ether they would like to sell an item for. A buyer must then also send twice the purchase price of Ether. At that point the contract is locked until a buyer calls confirmReceived at which point, the buyer and seller are returned half of what they deposited back. How does the seller then receive the remaining balance in the contract? Is it expected that a developer would include an additional withdrawal function for the seller?
Is the reasoning for depositing 2x the value supposed to act as a dispute resolution tool? It would seem that if confirmReceived is never called the Ether in the contract is essentially burnt?
Also am I correct in understanding that in order to take advantage of the ability for a buyer or seller to “block the refund” in confirmReceived their address would have to be a contract that had some logic within their fallback function to verify that the amount they were receiving is correct?
// This actually allows both the buyer and the seller to // block the refund. if (!buyer.send(value) || !seller.send(this.balance)) throw;