Skip to content

Instantly share code, notes, and snippets.

@ajuggler
Forked from brunjlar/metadata.json
Created June 9, 2022 23:07
Show Gist options
  • Save ajuggler/a39b2da0cca24489c18369ae72d095cb to your computer and use it in GitHub Desktop.
Save ajuggler/a39b2da0cca24489c18369ae72d095cb to your computer and use it in GitHub Desktop.
MPP - Double Pay
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
function doublePay (giver1: Party, giver2: Party, receiver: Party, amount: Value, deadline: Timeout): Contract {
const pay: Contract = Pay(
giver1,
Party(receiver),
ada,
amount,
Pay(
giver2,
Party(receiver),
ada,
amount,
Close));
function deposit (party: Party): Action {
return Deposit(party, party, ada, amount);
}
function deposits (p1: Party, p2: Party): Case {
return Case(
deposit(p1),
When(
[Case(
deposit(p2),
pay)],
deadline,
Close));
}
return When(
[deposits(giver1, giver2), deposits(giver2, giver1)],
deadline,
Close);
}
return doublePay(
Role("Giver1"),
Role("Giver2"),
Role("Receiver"),
ConstantParam("Deposit"),
TimeParam("Deadline"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment