Following Dazl Getting Started- not recognizing Parties in act_as

Hi All,

I have been following the Dazl Getting started guide in the docs(dazl: DA client library for Python) and am having trouble hitting the api as a party. Code and error attached.


I tried to follow this thread: (How to obtain party identifiers in the `dazl-client` python library in 2.x.x?) . However my output json is only printing the contract ID not any of the party IDs.

I think it’s an issue with the setup script not actually allocating parties but haven’t had any luck pasting the entire partyID into the api call either.

YAML:
sdk-version: 2.6.0
name: dazl-test
source: daml
init-script: Main:setup
version: 0.0.1
dependencies:

  • daml-prim
  • daml-stdlib
  • daml-script
    script-options:
  • –output-file=parties.json

Setup Script:
– user_setup_begin
alice ← allocatePartyWithHint “Alice” (PartyIdHint “Alice”)
bob ← allocatePartyWithHint “Bob” (PartyIdHint “Bob”)
aliceId ← validateUserId “alice”
bobId ← validateUserId “bob”
createUser (User aliceId (Some alice)) [CanActAs alice]
createUser (User bobId (Some bob)) [CanActAs bob]
– user_setup_end

Thanks,
Bryan

Hey @barment,

the issue in your example is that you’re only using the party id hint (i.e. Alice) in act_as as opposed to the full party id that is returned by allocatePartyWithHint.

One option to find the full party id, is to change the Daml script to return the parties and then use --output-file like you are already doing. Here is an example:

data Parties = Parties with
    alice : Party
    bob : Party


setup = script do
  alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
  bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
  aliceId <- validateUserId "alice"
  bobId <- validateUserId "bob"
  createUser (User aliceId (Some alice)) [CanActAs alice]
  createUser (User bobId (Some bob)) [CanActAs bob]
  pure Parties with ..

The resulting JSON file will look something like this:

{
  "alice": "Alice::longhash",
  "bob": "Bob::longhash"
}

where Alice::longhash is the party id you’re looking for. Note that the hash will change if you restart your ledger.

Thanks - this cleared it up!