input-output-hk / marlowe-cardano

Marlowe smart contract language Cardano implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide `marlowe-cli` examples for timeouts and multiple inputs

bwbush opened this issue · comments

Only one of the existing examples in marlowe-cli/ shows how to handle timeouts with marlowe-cli run prepare, and there are no examples of applying several inputs in a single marlowe-cli run prepare.

Acceptance criteria:

  • Add example to marlowe-cli/lectures/ for execution of a timeout.
  • Add example to marlowe-cli/lectures/ for applying multiple inputs in the same prepare.
  • Record a brief video-screenshot lecture segment that walks through the above examples.

Excerpt from discussion on Discord:

When a contract times out and makes payments, those payments don't get automatically made, moving the relevant funds from the Marlowe script address to the payout address. (Remember that smart contracts in Cardano only operate during a transaction submitted by a user.) Instead, those payments need to be triggered by a transaction that spends the UTxO at the Marlowe script. In this case, the marlowe-cli run prepare won't contain a --deposit..., --choose..., or --notify because no input is being applied. It just has --invalid-before and --invalid-hereafter that fall at or after the moment of timeout. (There is an example of this type of prepare in Cell 63 of https://github.com/input-output-hk/marlowe-cardano/blob/640ff8bdf900ffa21ae6ba1d5627f8056ecbf252/marlowe-cli/cookbook/guessing-game.ipynb .) Anyone (not just the parties to the contract) can sign and submit such a transaction if they're willing to pay the transaction fee. Such a transactions will move the funds to the payout script address and then you can use the withdraw command as you tried. Let me know if this explanation make sense--it's a bit hard to briefly explain it in Discord chat.

This is an example of the general capability of the marlowe-cli run prepare command to apply zero or more inputs. Mostly, we just apply one input at a time, but one can apply no input (as in the case I just discussed) or multiple inputs (maybe a --choose... and followed by a --deposit). If the same party applies two inputs at once, then they only have to pay one transaction fee. All of the inputs need to be legal within the --invalid-before and --invalid-hereafter.