Skip to content

Instantly share code, notes, and snippets.

@gyorgybalazsi
Last active October 25, 2021 10:57
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/942ece43d556f018549c88c6614c189c to your computer and use it in GitHub Desktop.
Save gyorgybalazsi/942ece43d556f018549c88c6614c189c to your computer and use it in GitHub Desktop.
Daml template in one line
module Token where
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
do
createdAt <- getTime
create this with owner = newOwner
// Identical with the Token template
template Token1 with {issuer: Party; owner : Party; amount : Int} where {signatory issuer; observer owner; controller owner can Transfer1 : ContractId Token1 with {newOwner : Party} do (getTime >>= \createdAt -> create this with owner = newOwner)}
test : Script ()
test = do
issuer <- allocateParty "issuer"
owner <- allocateParty "owner"
newOwner <- allocateParty "newOwner"
let amount = 100
createdAt <- getTime
token <- submit issuer $ createCmd Token with ..
token1 <- submit issuer $ createCmd Token1 with ..
submit owner $ exerciseCmd token1 Transfer1 with ..
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment