Daml Shell
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.
The diagram below illustrates where Daml Shell sits within the overall architecture of a Canton ledger and how it interacts with PQS’s database:
flowchart LR
PQS --> |"Ledger API<br>(gRPC)"| Participant["Canton<br>Participant"]
PQS["PQS"] --> |"DML<br>(JDBC)"| PG
Shell["Daml Shell<br>(daml-shell.jar)"] -.-> |"SQL<br>(JDBC)"| PG["PostgreSQL"]
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
Java jar 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 |
|
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
Note
While Daml Shell’s configuration is read at start up many of the values can be adjusted interactively. Please consult the Interactive configuration section.
Consult 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 see [1]
Once configured, use appropriate values for dedicated parameters:
$ ./daml-shell.jar \
--postgres-tls-cert /path/to/postgres.crt \
--postgres-tls-key /path/to/postgres.der \
--postgres-tls-cafile /path/to/postgres.crt \
--postgres-tls-mode VerifyFull
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 downloaded jar file:
$ ./daml-shell.jar
Note
You will need to ensure you have a suitable Java Runtime Environment (17+) installed on your host
to run the .jar artifact
Docker image considerations
Due to Daml Shell being an interactive terminal application please ensure your docker run
command has the interactive (-i / --interactive) and TTY (-t / --tty)
arguments set as a TTY is required.
$ docker run --interactive --tty \
europe-docker.pkg.dev/da-images/docker/daml-shell:<version-tag>
Note
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:
$ ./daml-shell.jar --help
Usage: daml-shell [options]
-h, --help prints this usage text
--config <file> HOCON config file with settings as key-value pairs
-v, --version Print the version of Daml Shell
--wildcard-char <char> wildcard character used to abbreviate identifiers. Default: "…"
--identifier-hash-length <length>
Number of characters to render for hashes inside identifiers. Default: 20
--full-identifiers Disable identifier shortening.
--identifier-trim-location <leading|middle|trailing>
Where to trim long identifiers. Default: "trailing"
--completion-query-items <count>
How many completions to show unprompted. Default: 100
--disable-color Disable ANSI colored output.
--postgres-host <host> Postgres host to connect to. Implies --connect. Default: "localhost"
--postgres-port <port> Postgres port to connect to. Implies --connect. Default: 5432
--postgres-username <username>
Postgres username to connect with. Implies --connect. Default: "postgres"
--postgres-password <password>
Postgres password to connect with. Implies --connect. Default: none
--postgres-database <name>
Postgres database to connect to. Implies --connect. Default: "postgres"
--postgres-schema <schema>
Postgres schema to connect to. Implies --connect. Default: "public"
--postgres-tls-mode <Disable|VerifyCA|VerifyFull|Require>
TLS mode for Postgres connection. Implies --connect. Default: "Disable"
--postgres-tls-cafile <path>
Path to the TLS CA file for Postgres connection. Implies --connect. Default: none
--postgres-tls-cert <path>
Path to the TLS certificate file for Postgres connection. Implies --connect. Default: none
--postgres-tls-key <path>
Path to the TLS key file for Postgres connection. Implies --connect. Default: none
--connect Auto-connect to the database on startup.
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 the Transaction 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’s Transaction Tree Stream. Set --pipeline-datasource to TransactionTreeStream when running PQS, refer to the PQS documentation.
If you still don’t see choices, see Why don’t I see any archived contracts?
Why don’t I see any interface views?
Interfaces are only visible on the Ledger API’s Transaction 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?
Contribute
Please, visit https://discuss.daml.com/tag/daml-shell 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:
|
|
Wildcard character used to abbreviate identifiers. (default:
|
|
Number of characters to render for hashes inside identifiers. (default:
|
|
Disable identifier shortening.
|
|
Where to trim long identifiers. (default:
|
|
How many completions to show unprompted. (default:
|
|
Disable ANSI colored output (optional)
|
|
Postgres host to connect to. Implies –connect. (default:
|
|
Postgres port to connect to. Implies –connect. (default:
|
|
Postgres username to connect with. Implies –connect. (default:
|
|
Postgres password to connect with. Implies –connect. (default:
|
|
Postgres database to connect to. Implies –connect. (default:
|
|
Postgres schema to connect to. Implies –connect. (default:
|
|
TLS mode for Postgres connection. Implies –connect. (default:
|
|
Path to the TLS CA file for Postgres connection. Implies –connect. (default:
|
|
Path to the TLS certificate file for Postgres connection. Implies –connect. (default:
|
|
Path to the TLS key file for Postgres connection. Implies –connect. (default:
|
|
Auto-connect to the database on startup.
|
Interactive configuration
You can set or adjust configuration values interactively using the set command once Daml Shell
has been started.
Change the length of the identifier hash:
> set identifier-hash-length full
Disabled identifier shortening
Type help set or help set <setting> to learn more about specific settings:
> help set
NAME
set - configure application settings
SYNOPSIS
set [<command>]
DESCRIPTION
Available settings:
* postgres-database <database> - PostgreSQL database
* oldest <start|offset> - lower offset bound
* postgres-tls-key <path> - PostgreSQL TLS key file
* postgres-username <username> - PostgreSQL username
* postgres-port <port> - PostgreSQL port
* latest <end|previous|next|offset> - upper offset bound
* identifier-hash-length <length|full> - identifier length
* postgres-host <host> - PostgreSQL host
* disable-color - disable color output
* postgres-password <password> - PostgreSQL password
* postgres-tls-cafile <path> - PostgreSQL TLS CA file
* postgres-tls-cert <path> - PostgreSQL TLS cert file
* identifier-trim-location <leading|middle|trailing> - identifier trim location
* postgres-tls-mode <mode> - PostgreSQL TLS mode
* wildcard-char <char> - identifier wildcard
* enable-color - enable color output
* completion-query-items <count> - completion count