Last active
July 1, 2022 11:42
-
-
Save marco-martins/670832702aaa2c9258cfecef5a1b7fa3 to your computer and use it in GitHub Desktop.
Test Swap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment