Skip to content

Instantly share code, notes, and snippets.

@gyorgybalazsi
Last active October 26, 2021 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyorgybalazsi/dca881888fe9b1b5c461a59cd84d7b56 to your computer and use it in GitHub Desktop.
Save gyorgybalazsi/dca881888fe9b1b5c461a59cd84d7b56 to your computer and use it in GitHub Desktop.
transactions1.hs
module Token1 where
import Daml.Script
template Token
with
issuer : Party
owner : Party
amount : Int
createdAt : Time
where
signatory issuer
observer owner
controller owner can
Transfer : ContractId Token
with
newOwner : Party
-- This is a monadic transaction
do
getTime >>= \createdAt -> create this with owner = newOwner
test: Script [ContractId Token]
test = do
issuer <- allocateParty "issuer"
alice <- allocateParty "Alice"
bob <- allocateParty "Alice"
charles <- allocateParty "Charles"
dave <- allocateParty "Dave"
newOwner <- allocateParty "newOwner"
let amount = 100
createdAt <- getTime
-- This is an applicative transaction
sequence [ (submit issuer $ createCmd Token with owner = alice, ..)
, (submit issuer $ createCmd Token with owner = bob, ..)
, (submit issuer $ createCmd Token with owner = charles, ..)
, (submit issuer $ createCmd Token with owner = dave, ..)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment