Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/How can users query the ledger in Daml Script?Forum ↗

How can users query the ledger in Daml Script?

App Development3 posts216 views5 likesLast activity Jun 2022
GY
gyorgybalazsiOP
Jun 2022 1

In Daml Script, users can submit commands to the ledger via the submitUser command.

Is there an equivalent for querying the ledger? I couldn’t find any.

The query function and its relatives require an isParties instance and UserId is not one of them.

CO
cocreature
Jun 2022 4

At the moment there is no function for this. You can build your own as a wrapper. Something like

toParty : UserRight -> Optional Party
toParty ParticipantAdmin = None
toParty (CanActAs p) = Some p
toParty (CanReadAs p) = Some p

queryUser : forall t. Template t => UserId -> Script [(ContractId t, t)]
queryUser userId = do
  rights <- listUserRights userId
  query @t (mapOptional toParty rights)

Not opposed to adding it.

GY
gyorgybalazsi
Jun 2022

Thanks, Moritz, I think this could be helpful.

← Back to Discussions