Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/How to obtain the ContractId : JavaForum ↗

How to obtain the ContractId : Java

App Development2 posts339 views5 likesLast activity Jun 2021
TE
tejashree_parabOP
Jun 2021

Can we obtain the contractId on the submission of the command on the ledger? If so then how.

Like in JS we get it in callback response, so is there any functionality available in java for the same.

Are there any methods or sample projects available for reference?

ST
stefanobaghino-da
Jun 2021

If you are using the CommandClient you can submitAndWaitForTransaction, which returns a Transaction object that represents the result of the command you submitted, which in turn contains all the persistent events, including contract creations with their contract identifier. If you are interested in seeing the full transaction, including transient and non-consuming events you can use the submitAndWaitForTransactionTree method, which returns TransactionTrees for your command.

If you are using a mix of the CommandSubmissionClient, CommandCompletionClient and TransactionClient the latter offers methods to read both Transactions and TransactionTrees for the relevant commands you submitted.

You can read more about all of these in the reference documentation for the Java bindings (here for version 1.14.0).

← Back to Discussions