Skip to content

Instantly share code, notes, and snippets.

@devonartis
Created May 17, 2021 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devonartis/6712d8a81c5e69779f13d196e106cca0 to your computer and use it in GitHub Desktop.
Save devonartis/6712d8a81c5e69779f13d196e106cca0 to your computer and use it in GitHub Desktop.
Escrow with collateral
{"valueParameterDescriptions":[["Collateral amount","The amount of Lovelace to be deposited by both parties at the start of the contract to serve as an incentive for collaboration."],["Price","The amount of Lovelace to be paid by the *Buyer* as part of the exchange."]],"slotParameterDescriptions":[["Collateral deposit by seller timeout","The deadline by which the *Seller* must deposit the *Collateral amount* in the contract."],["Deposit of collateral by buyer timeout","The deadline by which the *Buyer* must deposit the *Collateral amount* in the contract."],["Deposit of price by buyer timeout","The deadline by which the *Buyer* must deposit the *Price* in the contract."],["Dispute by buyer timeout","The deadline by which, if the *Buyer* has not opened a dispute, the *Seller* will be paid."],["Seller's response timeout","The deadline by which, if the *Seller* has not responded to the dispute, the *Buyer* will be refunded."]],"roleDescriptions":[["Buyer","The party that pays for the item on sale."],["Seller","The party that sells the item and gets the money if the exchange is successful."]],"contractType":"ES","contractName":"Escrow with collateral","contractDescription":"Regulates a money exchange between a *Buyer* and a *Seller* using a collateral from both parties to incentivize collaboration. If there is a disagreement the collateral is burned.","choiceDescriptions":[["Confirm problem","Acknowledge that there was a problem and a refund must be granted."],["Dispute problem","The *Seller* disagrees with the *Buyer* about the claim that something went wrong and the collateral will be burnt."],["Everything is alright","The exchange was successful and the *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 "Seller")
(Token "" "")
(ConstantParam "Collateral amount")
)
(When
[Case
(Deposit
(Role "Buyer")
(Role "Buyer")
(Token "" "")
(ConstantParam "Collateral amount")
)
(When
[Case
(Deposit
(Role "Seller")
(Role "Buyer")
(Token "" "")
(ConstantParam "Price")
)
(When
[Case
(Choice
(ChoiceId
"Everything is alright"
(Role "Buyer")
)
[Bound 0 10000]
)
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]
)
(Pay
(Role "Seller")
(Party (PK "0000000000000000000000000000000000000000000000000000000000000000"))
(Token "" "")
(ConstantParam "Collateral amount")
(Pay
(Role "Buyer")
(Party (PK "0000000000000000000000000000000000000000000000000000000000000000"))
(Token "" "")
(ConstantParam "Collateral amount")
Close
)
)]
(SlotParam "Seller's response timeout")
Close
)
)]
(SlotParam "Dispute by buyer timeout")
Close
)]
(SlotParam "Deposit of price by buyer timeout")
Close
)]
(SlotParam "Deposit of collateral by buyer timeout")
Close
)]
(SlotParam "Collateral deposit by seller timeout")
Close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment