Skip to content

@sigilry/canton-json-api

@sigilry/canton-json-api provides TypeScript types and Zod schemas generated from the pinned Canton JSON Ledger API v2 OpenAPI spec. Use it to type and validate the bodies that flow through the CIP-103 ledgerApi method.

Terminal window
yarn add @sigilry/canton-json-api@^1

This package has its own 1.x version line. Wallet connectivity uses @sigilry/dapp@^3 and, for React, @sigilry/react@^3.

Schemas are named z<OperationOrType>. int64 fields, such as ledger offsets, are modeled as bigint after parsing.

import { zGetLedgerEndResponse } from "@sigilry/canton-json-api";
const parsed = zGetLedgerEndResponse.parse({ offset: "42" });
const offset: bigint = parsed.offset;
console.log(offset);

With React, pass a schema’s parse to useLedgerApi to get typed results. For a full holdings query through the wallet, see Read Holdings.

The package is generated from a checked-in OpenAPI snapshot (packages/canton-json-api/api-specs/openapi.yaml) pinned to a specific Canton release. CI runs codegen:check and fails when the generated files drift from that snapshot.