Skip to content

Instantly share code, notes, and snippets.

@manuschillerdev
Created May 13, 2021 09:24
Show Gist options
  • Save manuschillerdev/6ab0ae7c1d44964e3cb8735a2bb0be95 to your computer and use it in GitHub Desktop.
Save manuschillerdev/6ab0ae7c1d44964e3cb8735a2bb0be95 to your computer and use it in GitHub Desktop.
Simple escrow
{"valueParameterDescriptions":[["Price","Amount of Lovelace to be paid by the *Buyer* for the item."]],"slotParameterDescriptions":[["Buyer's deposit timeout","Deadline by which the *Buyer* must deposit the selling *Price* in the contract."],["Buyer's dispute timeout","Deadline by which, if the *Buyer* has not opened a dispute, the *Seller* will be paid."],["Seller's response timeout","Deadline by which, if the *Seller* has not responded to the dispute, the *Buyer* will be refunded."],["Timeout for arbitrage","Deadline by which, if the *Arbiter* has not resolved the dispute, the *Buyer* will be refunded."]],"roleDescriptions":[["Arbiter","The party that will choose who gets the money in the event of a disagreement between the *Buyer* and the *Seller* about the outcome."],["Buyer","The party that wants to buy the item. Payment is made to the *Seller* if they acknowledge receiving the item."],["Seller","The party that wants to sell the item. They receive the payment if the exchange is uneventful."]],"contractType":"ES","contractName":"Simple escrow","contractDescription":"Regulates a money exchange between a *Buyer* and a *Seller*. If there is a disagreement, an *Arbiter* will decide whether the money is refunded or paid to the *Seller*.","choiceDescriptions":[["Confirm problem","Acknowledge there was a problem and a refund must be granted."],["Dismiss claim","The *Arbiter* does not see any problem with the exchange and the *Seller* must be paid."],["Dispute problem","The *Seller* disagrees with the *Buyer* about the claim that something went wrong."],["Everything is alright","The transaction was uneventful, *Buyer* agrees to pay the *Seller*."],["Report problem","The *Buyer* claims not having received the product that was paid for as agreed and would like a refund."]]}
When [
(Case
(Deposit
(Role "Seller")
(Role "Buyer")
(Token "" "")
(ConstantParam "Price"))
(When [
(Case
(Choice
(ChoiceId "Everything is alright"
(Role "Buyer")) [
(Bound 0 0)]) Close)
,
(Case
(Choice
(ChoiceId "Report problem"
(Role "Buyer")) [
(Bound 1 1)])
(Pay
(Role "Seller")
(Account
(Role "Buyer"))
(Token "" "")
(ConstantParam "Price")
(When [
(Case
(Choice
(ChoiceId "Confirm problem"
(Role "Seller")) [
(Bound 1 1)]) Close)
,
(Case
(Choice
(ChoiceId "Dispute problem"
(Role "Seller")) [
(Bound 0 0)])
(When [
(Case
(Choice
(ChoiceId "Dismiss claim"
(Role "Arbiter")) [
(Bound 0 0)])
(Pay
(Role "Buyer")
(Party
(Role "Seller"))
(Token "" "")
(ConstantParam "Price") Close))
,
(Case
(Choice
(ChoiceId "Confirm problem"
(Role "Arbiter")) [
(Bound 1 1)]) Close)] (SlotParam "Timeout for arbitrage") Close))] (SlotParam "Seller's response timeout") Close)))] (SlotParam "Buyer's dispute timeout") Close))] (SlotParam "Buyer's deposit timeout") Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment