Skip to content

Instantly share code, notes, and snippets.

@gyorgybalazsi
Last active October 26, 2021 13:42
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/bf10868e851ab7e58ca019884c3bdf90 to your computer and use it in GitHub Desktop.
Save gyorgybalazsi/bf10868e851ab7e58ca019884c3bdf90 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ApplicativeDo #-}
module Token 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
createdAt <- getTime
create this with owner = newOwner
test : Script ()
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 with applicative do notation
submit issuer do
createCmd Token with owner = alice, ..
createCmd Token with owner = bob, ..
createCmd Token with owner = charles, ..
createCmd Token with owner = dave, ..
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment