Last active
October 26, 2021 14:05
-
-
Save gyorgybalazsi/dca881888fe9b1b5c461a59cd84d7b56 to your computer and use it in GitHub Desktop.
transactions1.hs
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 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