Last active
October 25, 2021 10:57
-
-
Save gyorgybalazsi/942ece43d556f018549c88c6614c189c to your computer and use it in GitHub Desktop.
Daml template in one line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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