# How to obtain the ContractId : Java

**URL:** <https://forum.canton.network/t/how-to-obtain-the-contractid-java/2791>\
**Category:** App Development\
**Tags:** daml, ledger-api\
**Created:** [June 30, 2021, 10:26am UTC](https://forum.canton.network/t/how-to-obtain-the-contractid-java/2791 "2021-06-30T10:26:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tejashree\_parab](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/tejashree_parab/32/2038_2.png) [@tejashree\_parab](https://forum.canton.network/u/tejashree_parab)\
**Post date:** [June 30, 2021, 10:26am UTC](https://forum.canton.network/t/how-to-obtain-the-contractid-java/2791/1 "2021-06-30T10:26:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [June 30, 2021, 12:31pm UTC](https://forum.canton.network/t/how-to-obtain-the-contractid-java/2791/2 "2021-06-30T12:31:47Z")

</div>

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 `TransactionTree`s for your command.

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

You can read more about all of these in the reference documentation for the Java bindings ([here](https://docs.daml.com/1.14.0/app-dev/bindings-java/javadocs/index.html) for version 1.14.0).
