Skip to content

Instantly share code, notes, and snippets.

@da-blog
Created July 31, 2023 19:24
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 da-blog/49bea5c0b4d6c2480ce0b7bf2f840b94 to your computer and use it in GitHub Desktop.
Save da-blog/49bea5c0b4d6c2480ce0b7bf2f840b94 to your computer and use it in GitHub Desktop.
module Main where
import Daml.Script
template T2
with
alice : Party
reader : Party
where
signatory reader
observer reader
controller alice can
T2_FetchById : ()
with
cid : ContractId CurrentPrice
do
fetch cid
pure ()
controller alice can
T2_FetchByKey : ()
with
operator : Party
do
fetchByKey @CurrentPrice operator
pure ()
template CurrentPrice
with
operator : Party
reader : Party
where
signatory operator
observer reader
key operator : Party
maintainer key
s = script $ do
alice <- allocateParty "Alice"
operator <- allocateParty "Operator"
reader <- allocateParty "Reader"
cid <- operator `submit`
createCmd CurrentPrice with
operator = operator
reader = reader
t2 <- submit reader $
createCmd T2 with alice, reader
submitMulti [alice] [reader] $
exerciseCmd t2 T2_FetchByKey with operator
pure ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment