How to Access Transaction Metadata (e.g., transaction ID, hash) for Each DAML Command

Hi everyone,

I’m working with DAML (using Canton and Daml Script), and I have a quick question about how to access transaction metadata, specifically:

  • Transaction ID
  • Transaction hash (if available)
  • Ledger offsets or node hashes
  • Any other unique identifier tied to the transaction or contract creation

For example, I’ve created a contract and received a response like this (simplified below):

{
“contractId”: “00897293…”,
“payload”: {
“instrumentId”: “Bill-002”,

},
“completionOffset”: “00000000000000000a”
}

While I do get the contractId and completionOffset, I’m trying to extract metadata that refers specifically to the transaction itself (not the payload), like the transaction hash, transaction ID, etc.

:red_question_mark: My key questions:

  1. How can I retrieve the transaction hash or transaction ID that corresponds to each contract creation or command?
  2. Is there a way to listen to or log transactions programmatically, e.g., using the JSON API or gRPC?
  3. Do I need to rely on Ledger API calls like GetTransactions to get this metadata?
  4. Can I extract this information using Daml Script or canton console?

I want to refer to contracts by their transaction context and not by my own input data or labels.

Any advice, examples, or documentation links would be greatly appreciated!

Thanks in advance :folded_hands:

Yes, you can rely on the Ledger API endpoints like GetTransactions to get that metadata.

I don’t recall seeing Daml Script related to this information.

There does appear to be a Canton Console object for interacting with transactions, though I personally have no experience using it.

The Participant Query Store may be helpful to you. It includes metadata accessible via SQL.

Are you targeting Canton 2.x or Canton 3.x?

Thank you for response. I’m using 2.9.7 canton open source.