Canton.Ledger.Pqs.Client 0.4.0-preview.1

Prefix Reserved
This is a prerelease version of Canton.Ledger.Pqs.Client.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Canton.Ledger.Pqs.Client" Version="0.4.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Canton.Ledger.Pqs.Client" Version="0.4.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Canton.Ledger.Pqs.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Canton.Ledger.Pqs.Client --version 0.4.0-preview.1
                    
#r "nuget: Canton.Ledger.Pqs.Client, 0.4.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Canton.Ledger.Pqs.Client@0.4.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Canton.Ledger.Pqs.Client&version=0.4.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Canton.Ledger.Pqs.Client&version=0.4.0-preview.1&prerelease
                    
Install as a Cake Tool

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 SingletonPqsClient 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 { /* ... */ };
});
  • Canton.Ledger.Grpc.Client - gRPC client for command submission
  • Daml.Runtime - Runtime types for generated Daml contracts
  • Daml.Codegen.CSharp - Code generator for Daml contracts
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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