Is it possible to parse a party name from text in DAML script

The Alice and Bob parties have been created and exist on different Daml-Driver-for-Corda participant nodes and do not currently know about each other.

I want to use Daml script to allow Alice to send a contract to Bob once Bob has shared his party identifier (‘D:bob:O:Tribeca:L:New York:C:US’) with Alice.

The problem is that there appears to be no way to parse a text string into a Party.

1 Like

Hi @simon,
For most usecases, I would recommend that you accept the parties you intend to reference as an argument instead of hardcoding them in your script. You can then specify those parties via --input-file as described in the documentation. That makes your script easily portable and not dependent on your particular ledger setup and the corresponding party ids.

That said, if you really do want to hardcode the party ids you can use partyFromText : Text -> Optional Party.


I actually wrote a full example that uses partyFromText by reading the parties (as Text) from input files here. I guess what @cocreature means is you could type the inputs as Party directly and thus avoid the call to partyFromText.

Exactly, there is no point calling partyFromText in that case since the JSON encoding of parties is just a string.

@cocreature / @Gary_Verhaegen - Using an input file works perfectly, many thanks.

Using an input-file worked great when when I was using a single parameter, when I changed my script to accept three arguments the daml script stopped working:
Screenshot 2021-03-10 at 14.35.25

This is because the input file only populates the first parameter, the solution is ensure that all parameters are structured into a single argument, like:
Screenshot 2021-03-10 at 14.36.42

This way a json array containing the arguments can be used in the input-file.

A better alternative may be use a data structure (like LedgerParties in the example docs)