Repository navigation
v0.6.0 β first stable release π
π Canton .NET SDK β 0.6.0
The Canton .NET SDK lets you build .NET applications on a Canton/Daml ledger with full type safety. dpm codegen-cs turns a Daml .dar archive into strongly-typed C#: records for every template and data type, typed choices, and Tryβ¦Async methods that create contracts and exercise choices. One transport-neutral ICantonLedgerClient then submits them over gRPC or the JSON Ledger API, with a PQS client, authentication, OpenTelemetry tracing and in-memory test doubles alongside.
0.6.0 is the first stable release. It's for .NET teams building applications on Canton.
π¦ What's included
All 16 NuGet packages share version 0.6.0 with the dpm codegen-cs component. They publish together; upgrade them together.
| Role | Packages |
|---|---|
| Codegen | oci://ghcr.io/peacefulstudio/dpm-codegen-cs:0.6.0 (the dpm component); Daml.Codegen.CSharp (the emitter as a library); Daml.Codegen.Intermediate (the Intermediate DAR contract it consumes) |
| Runtime | Daml.Runtime (the types generated code compiles against); Daml.Runtime.Grpc (proto Value β DamlValue conversion) |
| Ledger clients | Canton.Ledger.Grpc.Client (the default transport); Canton.Ledger.Rest.Client (the same surface over the JSON Ledger API); Canton.Ledger.Pqs.Client (typed queries over the Participant Query Store) |
| Abstractions and plumbing | Daml.Ledger.Abstractions (ILedgerClient); Canton.Ledger.Abstractions (ICantonLedgerClient, IAdminClient, IPqsClient); Canton.Ledger.Kernel (token providers, telemetry naming, opt-in retries) |
| Observability | Canton.Ledger.OpenTelemetry: one AddCantonLedgerInstrumentation() call |
| Raw Ledger API | Canton.Ledger.Grpc (gRPC stubs); Canton.Ledger.Rest (raw JSON Ledger API surface) |
| Testing | Canton.Ledger.Testing (FakeLedgerClient, FakeAdminClient, FakePqsClient); Daml.Ledger.Abstractions.Testing.Conformance (xUnit suite for any ILedgerClient); Daml.Codegen.Testing.Conformance (the conformance corpus, not for production) |
Ready-made bindings: Splice.* packages generated from the Splice 0.8.4 DARs (each at its DAR version with a .17 suffix, e.g. Splice.Api.Token.Holding.V1 1.0.0.17), and 8 Daml.Finance.* packages from Daml Finance 2.10.0 (each at its DAR version with a .16 suffix, e.g. Daml.Finance.Util.V4 4.0.0.16).
Canton.Ledger.Rest, the raw JSON Ledger API surface, is experimental and marked CANTONREST001.
π Getting started
Add the component to your daml.yaml (components: replaces the sdk-version: key). It decodes the DAR with a bundled JVM helper, so a JDK must be on PATH. Set DPM_AUTO_INSTALL=true so dpm fetches it on first use.
components:
- oci://ghcr.io/peacefulstudio/dpm-codegen-cs:0.6.0dpm build -o iou.dar
dpm codegen-cs --dar ./iou.dar --out ./Generated
dotnet add package Daml.Runtime --version 0.6.0
dotnet add package Daml.Ledger.Abstractions --version 0.6.0
dotnet add package Canton.Ledger.Grpc.Client --version 0.6.0
dotnet add package Microsoft.Extensions.DependencyInjectionThen connect, create an Iou, transfer it, and read what the new owner holds (using the sample Iou model):
using Canton.Ledger.Abstractions;
using Canton.Ledger.Grpc.Client;
using Daml.Ledger.Abstractions.Extensions;
using Daml.Runtime.Contracts;
using Daml.Runtime.Outcomes;
using Iou;
using Microsoft.Extensions.DependencyInjection;
using IouContract = Iou.Iou;
var services = new ServiceCollection();
services.AddLedgerClient(options => options.GrpcAddress = "https://localhost:5001");
services.AddAdminClient(options => options.GrpcAddress = "https://localhost:5001");
await using var provider = services.BuildServiceProvider();
var ledger = provider.GetRequiredService<ICantonLedgerClient>();
var admin = provider.GetRequiredService<IAdminClient>();
var alice = (await admin.AllocatePartyAsync("alice")).Party;
var bob = (await admin.AllocatePartyAsync("bob")).Party;
var created = await ledger.TryCreateAsync(
new IouContract(Issuer: alice, Owner: bob, Currency: "USD", Amount: 100m));
var iouId = created switch
{
ExerciseOutcome<ContractId<IouContract>>.One ok => ok.Result,
_ => throw new InvalidOperationException(created.ToString()),
};
var transferred = await iouId.TryTransferAsync(
ledger, new IouContract.Transfer(NewOwner: alice), bob);
if (transferred is not ExerciseOutcome<ContractId<IouContract>>.One)
throw new InvalidOperationException(transferred.ToString());
foreach (var iou in await ledger.SnapshotAsync<IouContract>(alice))
Console.WriteLine($"{iou.Id}: {iou.Data.Amount} {iou.Data.Currency} from {iou.Data.Issuer}");Prefer the JSON Ledger API? Reference Canton.Ledger.Rest.Client and register services.AddRestLedgerClient(options => options.HttpAddress = "http://localhost:7575") instead. Everything else stays the same. The full walkthrough, with the sample Daml model, is in the README.
π§© Supported versions
| Version | |
|---|---|
| .NET | 10 (net10.0) |
| Canton | 3.5.x; protos and JSON Ledger API spec pinned at 3.5.19. The REST client needs 3.5.10 or later |
| Daml SDK | 3.5.2 |
| Splice bindings | built from Splice 0.8.4 |
| Daml Finance bindings | built from Daml Finance 2.10.0 |
dpm codegen-cs platforms |
linux-amd64, linux-arm64, darwin-arm64, windows-amd64 (JDK on PATH) |
The SDK is pre-1.0: under SemVer 0.x, a release may change the public API without a major-version bump. The CHANGELOG records every change.
π Docs: README Β· code generation Β· ledger clients Β· DAR to NuGet Β· configuration Β· Canton versions
π Full changelog: CHANGELOG.md β 0.6.0
π Questions and bugs: GitHub issues
π€ Building on Canton? Peaceful Studio, which maintains this SDK, also offers consulting: write to info@peaceful.studio.
Packages, dpm bundles, the Intermediate DAR proto and SHA256SUMS are attached below.
Already on 0.6.0-preview.4? 0.6.0 contains exactly the same code: change the version and you're done.