With daml 2.0, the partys are named as party:hashkey, as a result, when i have to log in to the daml ui template, i have to copy the complete party id from a contract in navigator. I would like to log in using the username alice instead of alice:21312312…c123. So what is the best way to do this?
1 Like
We haven’t gotten around to updating daml-ui-template
to make use of the user concept in 2.0 yet. What has worked for me in a different codebase is the following:
- Change the startup script (that allocates parties) to return
Script [(Text, Party)]
- Return the list of tuples (partyName, party) from that script
- Add
script-options
to your daml.yaml file to output the returned data into a JSON file:
script-options:
- --output-file=ui/src/parties.json
- Import the JSON file in your UI code like this:
import partyList from "./parties.json";
- The
partyList
object is now the list of (partyName, party) tuples. A tuple is access via_1
and_2
fields - From here you can hook that information into your login flow such that you can login with party names instead of parties
The above is not something suitable for production, where I’d definitely suggest to make use of the user feature in 2.0, but it’s good enough for a demo codebase.
I’d also suggest to have a look at how our “getting started” example (create-daml-app
) does it.
1 Like