Ro5s / BillOfSale

Demo on OpenLaw.io
1 stars 0 forks source link

Add 'abort' option for buyer (reclaim price deposit) #1

Open Ro5s opened 5 years ago

Ro5s commented 5 years ago

Something like this: /// Abort the promise and reclaim the ether collateral. /// Can only be called by the promisor before /// the contract is locked. function abort() public onlyPromisor inState(State.Created) { emit Aborted(); state = State.Inactive; promisor.transfer(address(this).balance); }

Ro5s commented 5 years ago

Realizing that these issue descriptions are pretty terrible. If any bnty-seekers stumble by here, hope you tolerate this kind of salad and such

PeterMPhillips commented 5 years ago

Hi Ross, I've read some of your medium articles and really like the work you're doing. I agree that the bill of sale contract needs to have an abort() function but I think there needs to be a way to prevent a buyer from taking back the money after receiving their goods/service. I think there needs to be an additional state that flips who gets to call the abort function.

So the buyer can call abort anytime before the product has shipped and only the seller may call it after the product has shipped. So I think there would be 4 states: 'initialized', 'shipped', 'received', 'cancelled'.

Then your abort function can look something like this:

function abort() external { require((state == 'initialized' && msg.sender == buyer) || (state == 'shipped' && msg.sender == seller)); state = 'cancelled'; buyer.transfer(address(this).balance); emit Aborted(); }

Let me know your thoughts. Regards.

P.S. Have you ever looked into Kleros for on-chain dispute resolution?

Ro5s commented 5 years ago

HI @PeterMPhillips,

Thank you kindly for reviewing my code (& for your nice comments, to boot)! 🙌

So, to add this fix, I would basically need to associate emits (e.g., 'initialized' when recordContract function called.....)?

I am on the road, but really look forward to testing this out! Thanks again

Ro5s commented 5 years ago

(Also, I have not looked into Kleros, will check that out as well)

PeterMPhillips commented 5 years ago

Exactly. When recordContract() is called, set state = 'initialized';

When confirmReceipt() is called, set state = 'received';

You would also need a function for the seller to call when the product is shipped: function confirmShipped(){ require(msg.sender == seller); state = 'shipped'; emit Shipped(now); }

event Shipped(uint timestamp);

Ro5s commented 5 years ago

Oh, btw @PeterMPhillips, feel free to claim this bounty for BRLN (commemorative curioso from EthBerlin event..): https://explorer.bounties.network/bounty/2239