Given a participants.json from project:DABL, how do I get my party in Daml Script?
- bernhardOP 1
I’ve downloaded the
participants.jsonfrom DABL, which contains something akin to what’s shown in https://docs.daml.com/daml-script/index.html#using-daml-script-in-distributed-topologies."party_participants": { "ledger-party-abc123": "bernhard", "public-ledgerid": "public" }However, there are dozens and dozens of other parties on my ledger. All have displayName=party and all have isLocal=True.
Is there any way in Daml Script to get my hands on my ledger party without passing in its Party Id or hardcoding it in my script?
- cocreature
On most ledgers you can call
listKnownPartiesand then get the party with the given display name (note that uniqueness of display names is not guaranteed by the ledger so you have to ensure that yourself). However, DABL does not (yet) implement that endpoint I believe so this unfortunately doesn’t work.This leaves passing the party id in from the outside as your only option. Assuming the participant names in the config generated by DABL correspond to display names, you could use
jqto go fromparticipants.jsonto a map of display names to party ids:> echo '{"party_participants": {"a-id": "a", "b-id": "b"}}' | jq ".party_participants | to_entries | map( {(.value) : .key } ) | add" { "a": "a-id", "b": "b-id" }You can then use a
TextMap Partyas the input your DAML Script and index that by display name to get the corresponding party id.