Skip to main content

Crate canton

Crate canton 

Source
Expand description

The Canton Network Rust SDK — one-stop entry point.

This crate is a thin facade over the canton-* family: it contains no logic of its own, only re-exports, so cargo add canton brings in the whole SDK as one coherent, version-locked set. Each member crate can also be used directly (cargo add canton-ledger) when only a subset is needed.

ModuleCrateWhat it is
ledgercanton-ledgerThe async Ledger API v2 client (gRPC + JSON + WebSocket)
authcanton-authJWT/OIDC authentication (client-credentials, caching, refresh)
admincanton-adminParty management, user self-inspect, topology read
damlcanton-damlThe runtime under generated bindings: Daml primitives, codecs, command builders
signercanton-signerPluggable signing for interactive submission — Ed25519 built in, HSM/KMS via the trait
tokencanton-tokenToken-standard workflows: CIP-56 at the root, CIP-0112 under token::v2
pqscanton-pqsTyped reads from the Participant Query Store (pqs-tls for TLS)

The shared foundation (canton-core: Config, Error, TLS, retry) is re-exported at the crate root — the same types canton-ledger itself re-exports, so both entry points name identical items.

§Typed bindings

daml is the runtime half of the codegen story: generated bindings depend on it (as rt) for daml::Party, daml::ContractId, the Template/Choice traits, and the command builders. It is re-exported here so a cargo add canton user gets a version-locked runtime without a second dependency line.

Generating the bindings themselves is a build-time step, so the generator is deliberately not re-exported: install the CLI with cargo install canton-codegen-cli, or depend on canton-codegen from a build script.

§Feature flags

Features are forwarded to the crates that implement them:

  • ws — WebSocket streaming for the JSON transport (canton-ledger/ws).
  • otel — OTLP export + W3C trace-context propagation (canton-ledger/otel).
  • ed25519 (default) — the in-memory Ed25519 key in canton-signer. Turn it off (default-features = false) when every signature comes from an HSM or KMS behind your own Signer implementation.
  • pqs-tls — TLS for the Participant Query Store connection (canton-pqs/tls).

§Quickstart

use canton::ledger::{CantonClient, Config};

let client = CantonClient::connect_lazy(Config::new("http://localhost:3901"))?;
println!("ledger api version: {}", client.version().await?);

This SDK is a community project funded by Canton dev-fund proposal #407; it is not an official Digital Asset product.

Re-exports§

pub use canton_admin as admin;
pub use canton_auth as auth;
pub use canton_daml as daml;
pub use canton_ledger as ledger;
pub use canton_pqs as pqs;
pub use canton_signer as signer;
pub use canton_token as token;

Modules§

localnet
Reading a local development network out of the environment — the variables canton-devkit localnet env exports, and the party ids that come with them. Reading a local development network out of the environment.
telemetry
What the SDK emits, and how to export it: the span and metric names, the transport labels they carry, and — behind otel — the OTLP setup for both signals. An application building a dashboard needs these, and reaching them meant depending on canton-core directly, which cargo add canton does not do. Telemetry: tracing spans, metrics, and structured events for client calls.

Structs§

Config
Configuration for an SDK gRPC client (shared by canton-ledger and canton-admin).
ErrorInfo
Structured google.rpc.ErrorInfo details from a gRPC status: the machine- readable reason, its domain, and error metadata. #[non_exhaustive].
ResourceInfo
A resource a failure is about, from a google.rpc.ResourceInfo detail on a gRPC status or an entry of a JSON API error body’s resources. #[non_exhaustive].
RetryConfig
Retry policy for unary calls.
TlsConfig
TLS settings for the gRPC channel.

Enums§

Auth
How the client authenticates each request.
Error
The single error type for the whole Canton Rust SDK.
ErrorCategory
Canton’s error categories — the coarse classification every Ledger API error carries (ErrorInfo.metadata["category"]), which the error-code documentation defines retryability on. #[non_exhaustive]: Canton may add categories.

Traits§

TokenSource
A source of bearer tokens for request authentication.

Type Aliases§

Result
SDK-wide result alias. Re-exported by the facade as canton::Result.