Skip to content

Instantly share code, notes, and snippets.

@marco-martins
Last active July 1, 2022 11:42
Show Gist options
  • Save marco-martins/670832702aaa2c9258cfecef5a1b7fa3 to your computer and use it in GitHub Desktop.
Save marco-martins/670832702aaa2c9258cfecef5a1b7fa3 to your computer and use it in GitHub Desktop.
Test Swap
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
const seller: Party = Role("Seller");
const buyer: Party = Role("Buyer");
const deadline: Timeout = TimeParam("Deadline");
const sellerAmount: Value = ConstantParam("Seller Amount");
const buyerAmount: Value = ConstantParam("Buyer Amount");
const sellerMakeDeposit = (): Action =>
Deposit(seller, seller, ada, sellerAmount)
const buyerMakeDeposit = (): Action =>
Deposit(buyer, buyer, ada, buyerAmount)
const makePayments = (): Contract =>
// seller send his amount to the buyer
Pay(seller, Party(buyer), ada, sellerAmount,
// buyer send his amount to the seller
Pay(buyer, Party(seller), ada, buyerAmount, Close))
const contract = (): Contract =>
When([
Case(
sellerMakeDeposit(),
When([Case(
buyerMakeDeposit(),
makePayments()
)],
deadline, Close)
)],
deadline, Close
)
return contract()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment