Skip to content

Instantly share code, notes, and snippets.

@Dave-Lindberg
Created June 10, 2022 04:32
Show Gist options
  • Save Dave-Lindberg/10c8195af8df61e84ca8c97a0b4f9b10 to your computer and use it in GitHub Desktop.
Save Dave-Lindberg/10c8195af8df61e84ca8c97a0b4f9b10 to your computer and use it in GitHub Desktop.
week-4_double-donation-haskell
{-# LANGUAGE OverloadedStrings #-}
module Example where
import Language.Marlowe.Extended
main :: IO ()
main = printJSON $ contract "giver1" "giver2" "receiver" "amount" "deadline"
{- Define a contract, Close is the simplest contract which just ends the contract straight away
-}
contract :: Party -> Party -> Party -> Value -> Timeout -> Contract
contract giver1 giver2 receiver amount deadline =
When
[deposits giver1 giver2, deposits giver2 giver1]
deadline
Close
where
pay :: Contract
pay =
Pay
giver1
(Party receiver)
ada
amount
(Pay
giver2
(Party receiver)
ada
deadline
Close
)
deposit :: Party -> Action
deposit p =
Deposit p p ada $ ConstantParam "Deposit"
deposits :: Party -> Party -> Case
deposits p1 p2 =
Case
(deposit p1)
(When
[Case (deposit p2) pay]
(TimeParam "Deadline")
Close
)
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment