I was wondering how can I execute DAML smart contract deployed on the Canton? on DABL it is fairly easy to do with API. does canton provide any API gateway like this? or we should be using API gateway created my daml json-api
command ?
Great question (that I unfortunately don’t have the answer to). Moving it to a separate topic thread since it’s a separate question. We ideally want one question per topic.
Sure @anthony I will keep that in mind!
All DAML Ledgers, with the exception of DABL, expose the DAML Ledger API, which is a gRPC based event sourcing API. Most ledgers only expose that API.
DABL only exposes the JSON API, which is an additional runtime component. It connects to the Ledger API on one side and exposes a simpler state-based HTTP/JSON one on the other. If you want to use it with Canton, you need to run it yourself with daml json-api
, as you suggested.
Like @bernhard said, you have a choice between gRPC and JSON APIs. This tutorial shows how to use Canton together with the JSON API. If you’re just experimenting, Canton’s console also provides some utility commands to access the gRPC API:
https://www.canton.io/docs/stable/user-manual/usermanual/console.html#ledger-api-access
The most convenient way to use these console commands is in combination with the DAML to Scala Codegen tool. Canton’s Getting Started Guide shows an example, though it’s not the focus of the document so it’s not really a step-by-step guide.
okay, thanks for the reply @bernhard.
so while using it with canton. if I make a transaction through the DAML json-api
can you please tell me what will be the transaction life cycle? or point me to the document which explains this?
okay I have been checking out canton’s console. but I’m more interested in the JSON-API as in my use-case frontend will be making calls to the DAML ledger hosted on canton.
The JSON API will forward the transaction to the gRPC API. From there, the internal life cycle depends on the particular implementation. For Canton-based implementations, you can have a look here:
https://www.canton.io/docs/stable/user-manual/architecture/overview.html
After the transaction is committed (or fails to commit), you’ll be notified on the gRPC API. The JSON API will then pick up this information and forward it to your app, though I’m not familiar with how this is implemented.