Skip to content

Instantly share code, notes, and snippets.

@rudolph9
Last active October 28, 2019 19:29
Show Gist options
  • Save rudolph9/50388601108aa2ef1aeaccc6b4e63dc9 to your computer and use it in GitHub Desktop.
Save rudolph9/50388601108aa2ef1aeaccc6b4e63dc9 to your computer and use it in GitHub Desktop.
Marlowe Smart Contract
{-# LANGUAGE OverloadedStrings #-}
module Swap where
import Language.Marlowe
main :: IO ()
main = print . pretty $ contract
{- Simply swap two payments between parties -}
contract :: Contract
contract =
When [Case (Deposit (AccountId 1 "CertRecipient") "CertRecipient" (Constant 1))
(When [Case (Deposit (AccountId 2 "CertRecipient") "CertRecipient" (Constant 1))
(When [Case (Choice (ChoiceId "Base10HashOfCert" "CertIssuer") [(Bound 0 256)])
(Pay (AccountId 1 "CertRecipient")
(Party "CertIssuer")
(AvailableMoney (AccountId 1 "CertRecipient"))
(Pay (AccountId 2 "CertRecipient")
(Party "CertRevoker")
(AvailableMoney (AccountId 2 "CertRecipient"))
(When [Case (Choice (ChoiceId "CertRvoked" "CertRevoker") [(Bound 0 1)])
Refund] 25 Refund)))] 20 Refund)] 20 Refund)] 15 Refund
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment