Run Daml Script agains Canton (in docker)

Hi daml community!
I’m running canton inside docker container. I can upload dar files to the container using

  1. ledger api
  2. json_api
  3. I can map dar file from local files to container volume on container startup

If I use 3rd do I need to run additional commands to upload the dar to participants and use daml code?
Is there a way to run daml script agains canton ledger like I do with sandbox:
daml script --dar ... --ledger-host ... --ledger-port ...
Looks like canton image don’t have daml command installed…
Maybe I can do this if I run json-api container alongside with canton? Using --json-api with daml script
Now I use 1 way (ledger_api). I upload dar from Java app, it is working fine! Now I wonder is there a way to run scripts against Canton.
Thanks for reading :slight_smile:

Hi @VictorShneer,

Daml Script should work against a Canton participant. Can you describe what you have tried and what error you have encountered?

Hi @Gary_Verhaegen thanks for the reply!

I run canton container using java testcontainer library
My COMMAND is
bin/canton daemon -Dcanton.participants.participant1.ledger-api.address=0.0.0.0 --no-tty --config examples/01-simple-topology/simple-topology.conf --bootstrap examples/01-simple-topology/simple-ping.canton

Also I load dar and daml code inside container via volumes. I can see my files when I exec shell my container.

Then I try to “execute in container” this
sh -c daml script --dar ...
or bin/daml. And this doesn’t work. I see that I have no daml installed in the container.
The error is
Error: sh: daml: not found
I use digitalasset/canton-open-source as the image

Why do you want to run daml-script within the container?

The Canton image is meant to simulate a production server running on a remote machine; in that context, you typically do not have the option of getting inside the container to run commands. But daml-script is not a special thing that needs to run on the same server as the ledger; it’s a normal Ledger API client application, going through the exact same APIs you would go through in any client code you’d write.

So the answer here is to keep your DAR files on the client, and run daml-script from the client, against the gRPC endpoint that the participant exposes (by default 6865, but may depend on your configuration).

Understood! Thx

I work with this lib.
I updated it to work with junit5 and daml > 2.0. Then I saw @Jean_Safar1 PR. Jean added testcontainer support. As I see the idea is to run a sandbox ledger inside container for every test method. It is cool because it allows to run tests in parallel.
I recognize circle ci errors and decided that if I merge everything together (junit5+daml2+testcontainer) it can work.

On my branch I did some progress - I can run canton inside container using testcontainer, I can allocate parties, load dars with ledger-api grpc, create contracts and fetch them. But I cannot run scripts inside container. For non-container ledger lib supports scripts so I tried to add it to container version as well.
Probably I don’t need it. We use this library without containers feature in the last project, and we don’t use scripts.

Basically what I’m doing is learning canton+daml and trying to make something useful at the same time :slight_smile:

At some point you may want to look into caching & pinning & so on, but as a stop-gap measure there’s always curl https://get.daml.com | sh.

1 Like