canton-network-docs
Daml Shell
Daml Shell - Canton Network Docs
Skip to main content
Consult
Type
See
The status bar shows the connected status, the session offset range, and the datastore offset range.
If you omit the package name, payloads from all package names are returned, as long as they have the same name.
The auto-completion provides both FQN variants (with and without package name).
You can also compare two contracts in a
You can look up exercises for a specific choice:
To look up individual exercises, use the event ID:
Filtering with
To refine your queries when listing contracts, you can use
Here are some examples of how to use
You can then write this output to a file by piping it through the
The
Documentation Index
Fetch the complete documentation index at: https://docs.canton.network/llms.txt
Use this file to discover all available pages before exploring further.
Daml Shell
Daml Shell is a component that enables you to interactively query ledger data made available in the Participant Query Store (PQS) PostgreSQL database.
Overview
Daml Shell provides an interactive terminal session to examine the current and historical state of the ledger by querying ledger transactions and associated events (creates and exercises/archives) stored in a PostgreSQL database by an active PQS deployment. With Daml Shell you can do the following:- Find a specific contract and display it. For example, if you have a contract ID, you can use Daml Shell to inspect the corresponding contract using the
contractcommand. - Find all events related to a transaction ID. A transaction is displayed as a series of ledger events (creates, archives, and exercises).
- Auto-completion for identifiers such as contract IDs, fully qualified names, and package names.
- List active, inactive, or all contracts for a template using a template FQN.
- Apply queries and filters to commands to manage the output.
- Use the
compare-contractscommand to highlight the delta between two contract IDs for the same template. - Query between a range of offset values.
Compatibility
Daml Shell is compatible with multiple versions of PQS:| Dependency | Versions |
|---|---|
| PQS | >= 0.4.11 |
| postgres-document.schema | >= 014 |
Download
Daml Shell is only available to enterprise customers. Daml Shell is available as both a Javajar file and a Docker container image.
| Source | Location |
|---|---|
| Browse UI | https://console.cloud.google.com/artifacts/docker/da-images/europe/public/docker%2Fdaml-shell |
| Docker Registry | europe-docker.pkg.dev/da-images/public/docker/daml-shell |
Configure
Daml Shell ascertains its configuration from the following sources, in order of priority:- HOCON configuration files (
--configargument) - Command-line arguments
- Java system properties (
-Darguments tojavacommand) - Environment variables
- Interactively via
setcommand once running
While Daml Shell’s configuration is read at start up many of the values can be adjusted interactively. Please consult the
build_daml_shell_interactive_configuration section.build_daml_shell_configuration_options for all available configuration options.
Secure
Daml Shell is a client to PostgreSQL database as such it needs to respect security settings mandated by those services - TLS and authentication:TLS
Your server-side components (PostgreSQL) may require TLS to be used. Please refer to their documentation for instructions:- for PostgreSQL see1
Operate
Pre-requisites
To run Daml Shell you need the following:
- PQS deployment with Populated PostgreSQL database
- Daml Shell application jar or Docker image
Run Daml Shell
Daml Shell is an interactive client and requires a PQS database. Start Daml Shell with a downloadedjar file:
You will need to ensure you have a suitable Java Runtime Environment (17+) installed on your host to run the
.jar artifactDocker image considerations
Due to Daml Shell being an interactive terminal application please ensure yourdocker run command has the interactive (-i / --interactive) and TTY (-t / --tty) arguments set as a TTY is required.
If using container orchestration tooling such as Docker Compose or Kubernetes, please consult the respective documentation for enabling TTY and interactivity for Daml Shell
Get help
Exploring configuration options is easiest via the--help argument:
Troubleshoot
Why don’t I see any archived contracts?
If you don’t see any archived contracts, PQS might be configured to seed the database from the latest available ACS, which does not include historical events. To see pre-existing archived contracts, seed the database from theTransaction Stream or Transaction Tree Stream.
To ingest as much history as possible, set --pipeline-ledger-start to Genesis when running PQS for the first time, refer to the PQS documentation.
Why don’t I see any choices?
Choices are only visible on the Ledger API’sTransaction Tree Stream. Set --pipeline-datasource to TransactionTreeStream when running PQS, refer to the PQS documentation.
If you still don’t see choices, see build_daml_shell_no_archived_contracts
Why don’t I see any interface views?
Interfaces are only visible on the Ledger API’sTransaction Stream or ACS (not the Transaction Tree Stream).
Set --pipeline-datasource to TransactionStream when running PQS, refer to the PQS documentation.
Why do all contracts show the same ledger offset?
Seebuild_daml_shell_no_archived_contracts
Contribute
Please, visit https://forum.canton.network/ to ask questions and raise feature requests.References
Configuration options
./daml-shell.jar parameters
| Parameter | Description |
|---|---|
Path to configuration overrides via an external HOCON file (optional) + Environment variable: DAML_SHELL_CONFIG. System property: config. | |
Wildcard character used to abbreviate identifiers (default: …). Environment variable: DAML_SHELL_WILDCARD_CHAR. System property: wildcard-char. | |
Number of characters to render for hashes inside identifiers. (default: 20). Environment variable: DAML_SHELL_IDENTIFIER_HASH_LENGTH. System property: identifier-hash-length. | |
Disable identifier shortening.. Environment variable: DAML_SHELL_FULL_INDENTIFIERS. System property: full-identifiers. | |
Where to trim long identifiers. (default: trailing). Environment variable: DAML_SHELL_IDENTIFIER_TRIM_LOCATION. System property: identifier-trim-location. Enumeration values: leading, middle, trailing. | |
How many completions to show unprompted. (default: 100). Environment variable: DAML_SHELL_COMPLETION_QUERY_ITEMS. System property: completion-query-items. | |
Disable ANSI colored output (optional). Environment variable: DAML_SHELL_DISABLE_COLOR. System property: disable-color. | |
Postgres host to connect to. Implies —connect. (default: localhost). Environment variable: DAML_SHELL_POSTGRES_HOST. System property: postgres-host. | |
Postgres port to connect to. Implies —connect. (default: 5432). Environment variable: DAML_SHELL_POSTGRES_PORT. System property: postgres-port. | |
Postgres username to connect with. Implies —connect. (default: postgres). Environment variable: DAML_SHELL_POSTGRES_USERNAME. System property: postgres-username. | |
Postgres password to connect with. Implies —connect. (default: none). Environment variable: DAML_SHELL_POSTGRES_PASSWORD. System property: postgres-password. | |
Postgres database to connect to. Implies —connect. (default: postgres). Environment variable: DAML_SHELL_POSTGRES_DATABASE. System property: postgres-database. | |
Postgres schema to connect to. Implies —connect. (default: public). Environment variable: DAML_SHELL_POSTGRES_SCHEMA. System property: postgres-schema. | |
TLS mode for Postgres connection. Implies —connect. (default: Disable). Environment variable: DAML_SHELL_POSTGRES_TLS_MODE. System property: postgres-tls-mode. Enumeration values: Disable, VerifyCA, VerifyFull, Require. | |
Path to the TLS CA file for Postgres connection. Implies —connect. (default: none). Environment variable: DAML_SHELL_POSTGRES_TLS_CAFILE. System property: postgres-tls-cafile. | |
Path to the TLS certificate file for Postgres connection. Implies —connect. (default: none). Environment variable: DAML_SHELL_POSTGRES_TLS_CERT. System property: postgres-tls-cert. | |
Path to the TLS key file for Postgres connection. Implies —connect. (default: none). Environment variable: DAML_SHELL_POSTGRES_TLS_KEY. System property: postgres-tls-key. | |
Auto-connect to the database on startup.. Environment variable: DAML_SHELL_CONNECT. System property: connect. |
Interactive configuration
You can set or adjust configuration values interactively using theset command once Daml Shell has been started.
Change the length of the identifier hash:
help set or help set to learn more about specific settings:
How to inspect the ledger using Daml Shell
Connect to a PQS datastore
Daml Shell connects to the PostgreSQL database that is populated by a running Participant Query Store service via JDBC. You can set connection parameters via configuration file, command line arguments and environment variables at run time or interactively using a JDBC URL.build_daml_shell_configuration_options for available ways to configure Daml Shell.
To connect interactively, use the connect command and enter the JDBC URL of your PQS PostgreSQL database:
Query contract data
Daml Shell allows you to query ledger date in many different ways.Query at offsets
By default, offsets have leading zeroes removed. To see all identifiers in full, including contract ID hashes, runset identifier-hash-length full or set a custom length limit for hashes by running, for example, set identifier-hash-length 15.
Depending on the ledger implementation, offsets may be in hexadecimal format.
The available offset range from the datastore is specified in the Datastore range status field. The offset range for Daml Shell to use to display payload counts and summaries is specified in the Session range status field.
You can move to different offsets by using the go command, which is an alias for set latest. go -2 (go backward two offsets), go +2 (go forward two offsets), go forward (alias go next), go back (alias go backward), go start, and go end are all examples of valid commands.
The net-changes command summarizes the changes effected by the transaction at the current offset. The net-changes command also accepts a target offset argument, or two offset arguments to compare between (see help net-changes).
Contract summaries
Commands such asactive, archives, creates, and exercises can be used without argument to see payload counts by fully qualified identifier names. For details, run help.
Payloads by fully qualified name
Specify a fully qualified name (FQN) with the commandactive, archives, creates, or exercises to list all applicable payloads for that FQN.
To return payloads from a particular package only, include the package name in the FQN:
Look up a contract by ID
You can look up contracts by contract ID. Interface views are also displayed, if any. The contract ID can be copied with the wildcard character (here ”…”) included. The wildcard character will be expanded to any matching ID.diff-style output format using the compare-contracts <id1> <id2> command:
Look up a Transaction ID
You can look up transactions by either transaction ID or offset, by running transaction or transaction at, respectively. Note theat syntax when looking up by offset.
To display the current transaction at the head of the session offset range, run transaction.
The transaction command shows which contracts were created, which were archived, and what choices were exercised. It also displays the event ID for each of those events, as well as contract IDs and package names.
Look up an exercise
Exercised choices can be looked up in the same manner as contracts, except that exercises are looked up by their event ID rather than by a contract ID. The commands for summaries and lookups mirror the functionality available for contracts. For example, you can look up exercise counts by FQN:Refining and filtering your queries
Filtering with where clauses
To refine your queries when listing contracts, you can use where clauses to filter on specific payload fields. The where clauses use a SQL-like syntax for conditionals and are supported for the active, creates, archives, and exercises commands.
To access nested fields, use dot notation: parent.child.value
Comparison operators
=Equal to!=Not equal to>Greater than>=Greater than or equal to<Less than<=Less than or equal tolikeUsed for pattern matching,%serves as a wildcard character
Logical operators
and: Both conditions must be satisfiedor: Either condition may be satisfied
Type casting
To ensure proper comparison, you can optionally cast fields to a specific type using the:: operator. The available casting types are numeric, timestamp, and text.
Field values are sorted and compared lexicographically if no cast is specified.
where clause examples
Here are some examples of how to use where clauses in commands:
-
Filter by a string pattern:
Lists contracts where the
ownerfield starts with the stringAlice. -
Filter by a nested numeric field:
Lists contracts where the nested field
valueis greater than1000. -
Filter with exact string match (note the use of double quotes):
Lists contracts where the label field is exactly
loren ipsum. Use double quotes with values that contain whitespace characters. -
Combine different conditions:
Lists contracts where the
ownerstarts withBobor thevalueis less than100, andmyfieldismyvalue.
Setting offset bounds
The output ofcreates [<fqn>] and archives [<fqn>] can be bounded by set oldest (for the lower bound) and set latest (for the upper bound). go is an alias for set latest.
Finding transactions that created or archived a contract
Once you know the offsets that a contract was created at (for example, by using thearchives command), you can look up the relevant transactions using the transaction at command.
Transforming and exporting query output
You can convert tabular output to CSV by piping it through thecsv filter:
export filter:
export filter writes any command output to the specified file. You can use it without the csv filter.
Footnotes
-
https://www.postgresql.org/docs/current/ssl-tcp.html↩