Skip to content

Instantly share code, notes, and snippets.

@marco-martins
Last active June 14, 2022 15:53
Show Gist options
  • Save marco-martins/a8ef71ef055a359c6764fcc14146dab1 to your computer and use it in GitHub Desktop.
Save marco-martins/a8ef71ef055a359c6764fcc14146dab1 to your computer and use it in GitHub Desktop.
simple-payment-pay.js
{"valueParameterInfo":[["Deposit",{"valueParameterFormat":{"contents":[6,""],"tag":"DecimalFormat"},"valueParameterDescription":""}]],"timeParameterDescriptions":[],"roleDescriptions":[["Giver1",""]],"contractType":"Other","contractShortDescription":"","contractName":"Double Pay","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
function deposit (g: Party, amount: Value): Action {
return Deposit(g, g, ada, amount)
}
function pay (g: Party, r: Party, amount: Value): Contract {
return Pay(g, Party(r), ada, amount, Close)
}
// main function
function payment (giver: Party, receiver: Party, amount: Value, deadline: Timeout): Contract {
return When([
Case(
deposit(giver, amount),
pay(giver, receiver, amount)
)
], deadline, Close)
}
return payment(
Role("Giver"),
Role("Receiver"),
Constant(100000000),
TimeParam("Deadline")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment