The Canton console is built on Ammonite, a Scala-based scripting and REPL framework. Every command you type is valid Scala, which means you can write loops, define functions, bind variables, and compose operations just as you would in any Scala program. This page covers the practical side of scripting: how to writeDocumentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
.canton script files, how to run them, and common patterns for automating operator tasks.
Scala basics in the console
The console accepts standard Scala syntax. A few patterns come up repeatedly in operator scripts. Variable bindingSynchronizerAlias, Fingerprint, or Identifier, you can pass a plain String and it will be converted automatically.
Loading and running script files
Canton scripts use the.canton file extension by convention. You can run them in two ways.
Run a script at startup
interp.load mechanism or the utils helper:
run, the console stays open after the bootstrap script completes, which is useful for setting up initial state and then switching to interactive use.
Timeouts
Console command timeouts are configured in the Canton configuration file:boundedapplies to commands that are expected to complete within a known duration.unboundedapplies to long-running commands where completion time is unpredictable.
scala.concurrent.duration._ by default, so expressions like 10.seconds and 1.minute work without additional imports.
Automation patterns
Health checks
A simple health check script that verifies all local nodes are running:Batch operations
Upload a DAR to all local participants:participants.local, participants.remote, participants.all) support batch operations directly. You can also iterate when you need more control:
Scheduled tasks with external orchestration
The Canton console does not include a built-in scheduler. For recurring tasks, call your.canton scripts from an external scheduler such as cron or a Kubernetes CronJob:
.canton files while relying on battle-tested scheduling infrastructure.
Common scripting recipes
List connected synchronizers
Check party hosting
Export and import DARs
Remote administration
If your nodes run as daemons, you can script against them from a remote console. Configure a remote participant in your config:Some commands are only available from the local console of the node process itself. Remote consoles cover most administrative operations, but a few low-level operations require local access.
Tips for production scripts
- Always specify explicit timeouts rather than relying on defaults. A script that hangs indefinitely is harder to diagnose than one that fails fast.
- Use
try/catchblocks around operations that might fail, especially network calls and DAR uploads. - Log output with
printlnor write to files — the console does not persist output by default. - Keep scripts idempotent where possible. If a script is safe to re-run, recovery from partial failures is straightforward.
- Test scripts against a LocalNet environment before running them in production.