How to get command return value(s) when using Java bindings?

Hello daml forum,

I am submitting commands on contracts in the daml ledger, as a certain party.

For this purpose, I use CommandClient, that proposes 4 return choices : Empty, Transaction, TransactionId (String) and TransactionTree.

I tried them all and couldn’t find what I was looking for. What I want is the return value(s) of the command, as seen in the .daml code, example:

template SomeTemplate
  with
    someField: Text
 (...)
 where
  controller consumer can
      DoThis : **value(s) returned**

How can I do that from java reactive bindings?

Thank you in advance

1 Like

There is no method that only provides you with the return value of the choice you are exercising. However, the transaction tree (and only that) contains the result value in the ExercisedEvent.

In the simple case where you are only submitting a single exercise command, the root events will be a singleton list and contain the id of the exercise event you are looking for.

3 Likes

Thank you very much for such a rapid (instantaneous?) and exhaustive response.

I totally missed that ExercisedEvent.exerciseResult when looking at the transaction tree and this is exactly what I was looking for.

2 Likes