Canton.Ledger.Pqs.Client
0.4.0-preview.1
Prefix Reserved
dotnet add package Canton.Ledger.Pqs.Client --version 0.4.0-preview.1
NuGet\Install-Package Canton.Ledger.Pqs.Client -Version 0.4.0-preview.1
<PackageReference Include="Canton.Ledger.Pqs.Client" Version="0.4.0-preview.1" />
<PackageVersion Include="Canton.Ledger.Pqs.Client" Version="0.4.0-preview.1" />
<PackageReference Include="Canton.Ledger.Pqs.Client" />
paket add Canton.Ledger.Pqs.Client --version 0.4.0-preview.1
#r "nuget: Canton.Ledger.Pqs.Client, 0.4.0-preview.1"
#:package Canton.Ledger.Pqs.Client@0.4.0-preview.1
#addin nuget:?package=Canton.Ledger.Pqs.Client&version=0.4.0-preview.1&prerelease
#tool nuget:?package=Canton.Ledger.Pqs.Client&version=0.4.0-preview.1&prerelease
Canton.Ledger.Pqs.Client
Type-safe query client for the Canton Participant Query Store (PQS). Provides expression-based, SQL-injection-safe queries over active Daml contracts via PostgreSQL.
Overview
PQS exposes the ledger state as a PostgreSQL database. This package provides a strongly-typed client that queries active contracts using the generated Daml C# bindings. Filter field names are derived from expressions against those bindings, and values are always parameterized — eliminating SQL injection by construction.
Installation
dotnet add package Canton.Ledger.Pqs.Client
Usage
Basic Setup
using Canton.Ledger.Pqs.Client;
var options = new PqsClientOptions
{
ConnectionString = "Host=localhost;Database=pqs;Username=pqs;Password=pqs"
};
var pqsClient = new PqsClient(options);
Querying All Active Contracts
// Using generated template types from Daml.Codegen.CSharp
var agreements = await pqsClient.QueryAsync<Agreement>();
Querying with Filters
// Single field equality
var active = await pqsClient.QueryAsync<Agreement>(
Filter.Field<Agreement>(a => a.Status, "Active"));
// OR condition
var myAgreements = await pqsClient.QueryAsync<Agreement>(
Filter.Or(
Filter.Field<Agreement>(a => a.Initiator, partyId),
Filter.Field<Agreement>(a => a.Counterparty, partyId)));
// AND condition
var myActive = await pqsClient.QueryAsync<Agreement>(
Filter.And(
Filter.Field<Agreement>(a => a.Status, "Active"),
Filter.Or(
Filter.Field<Agreement>(a => a.Initiator, partyId),
Filter.Field<Agreement>(a => a.Counterparty, partyId))));
Fetching a Single Contract
// By filter (returns first match or null)
var contract = await pqsClient.QueryOneAsync<Agreement>(
Filter.Field<Agreement>(a => a.Initiator, partyId));
// By contract ID
var byId = await pqsClient.FetchByIdAsync<Agreement>(contractId);
// Check existence
var exists = await pqsClient.ExistsAsync<Agreement>(contractId);
Dependency Injection
The recommended DI lifetime is Singleton — PqsClient holds only configuration state and relies on Npgsql's built-in connection pooling for database connections.
// Using the extension method (recommended)
services.AddPqsClient(configuration.GetSection("Canton:Pqs"));
// Or using an action delegate
services.AddPqsClient(options =>
{
options.ConnectionString = "Host=localhost;Database=pqs";
});
// Health check (uses the configured connection string)
services.AddHealthChecks().AddPqsClient(tags: ["database", "ready"]);
OpenTelemetry Tracing
tracing.AddSource(PqsClient.ActivitySourceName);
Custom JSON Serialization
Override the default JsonSerializerOptions for contract payload deserialization using the action-based overload:
services.AddPqsClient(options =>
{
options.ConnectionString = "Host=localhost;Database=pqs";
options.JsonSerializerOptions = new JsonSerializerOptions { /* ... */ };
});
Related Packages
Canton.Ledger.Grpc.Client- gRPC client for command submissionDaml.Runtime- Runtime types for generated Daml contractsDaml.Codegen.CSharp- Code generator for Daml contracts
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Canton.Ledger.Kernel (>= 0.4.0-preview.1)
- Daml.Runtime (>= 0.4.0-preview.2)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.10)
- Npgsql (>= 10.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Canton.Ledger.Pqs.Client:
| Package | Downloads |
|---|---|
|
Canton.Ledger.OpenTelemetry
Opt-in OpenTelemetry wiring for the Canton Ledger API clients. AddCantonLedgerInstrumentation() registers the gRPC, admin, and PQS client ActivitySources plus Npgsql's own PostgreSQL instrumentation. The only assembly in this repo that depends on the OpenTelemetry SDK — the client libraries themselves emit only BCL System.Diagnostics.Activity. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.0-preview.1 | 71 | 7/18/2026 |
| 0.2.0-preview.1 | 88 | 7/6/2026 |
| 0.1.5-preview.1 | 66 | 6/25/2026 |
| 0.1.4-preview.1 | 60 | 6/15/2026 |