How to obtain party identifiers in the `dazl-client` python library in 2.x.x?

In 1.x, we could just the display names supplied when the Parties are allocated in API that calls that need Party IDs. In 2.x this is no longer possible, because the display names are no longer used as the party IDs.

Now, how do I obtain the actual Party IDs to be used in API calls. Specifically, how do I make the act_as argument in the connect call in the dazl API work:

    async with dazl.connect(url=FLAGS.ledger_backend,
                            act_as=[dazl.Party('A'), dazl.Party('B')]) as conn:
        await asyncio.gather(A(conn), B(conn))

A and B are the Party names used in daml.yaml. They used to work in 1.x, but in 2.x this yields an INVALID_PARTY_IDENTIFIER error message.

I recommend reading through our blogpost on parties & users in daml 2.0.

To answer your concrete question you first have to allocate your parties (e.g. via daml script’s allocateParty) and then use the result of that as your party id in dazl. One approach could be that your daml script writes out the party ids it has allocated to a json file via --output-file and you read that file in your python code.

1 Like

Thank you for the pointer, reading now.

I already found the hint to create a Daml script to initialize the parties, and to include it in daml.yaml. So I already have this:

init-script: Setup:initializeUser

Is there a way to obtain the output of the init-script specified in the daml.yaml file?

Is there a way to obtain the output of the init-script specified in the daml.yaml file?

OK, I found

daml start --script-option=--output-file="..."
1 Like

There is also a script-options section where you can specify this in your daml.yaml.

Thanks a lot. It works for me now. I marked the solutions above.

Cheers,
mesch.