Fetching a contract through the contract id on the ledger API

I would like to get the contract corresponding to a certain ContractId. What’s the recommended way to do so when using the gRPC Ledger API?

I saw that the JSON API exposes a fetch endpoint, but my application is directly using the Ledger API and I didn’t see a similar endpoint on the Ledger API.

2 Likes

Answer: currently, the simplest way to achieve this through the Ledger API is to query the ACS and filter that for the correct contract.

Another, more efficient option, is to build up an index over the ACS in the application, to avoid having to query the complete ACS for a simple look-up every time.

2 Likes