Last active
October 26, 2021 13:42
-
-
Save gyorgybalazsi/bf10868e851ab7e58ca019884c3bdf90 to your computer and use it in GitHub Desktop.
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
{-# 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