Skip to content

Canton Node SDK

LocalNet, signing, and transfers

Smoke-test cn-quickstart, external signing, and Amulet transfer offers on LocalNet.

LocalNet smoke

Prerequisites: cn-quickstart running with OAuth2 enabled (make setup → choose OAuth2, then make start).

The SDK ships repo scripts such as localnet:smoke / localnet:verify — see the package package.json in canton-node-sdk for the exact names on your branch.

From this documentation site, the fastest manual check is the maintained example:

cd canton-node-sdk
npx tsx examples/canton-quickstart.ts

Expected outcome: Console prints Ledger version, Validator DSO party (truncated), and Scan health status; process exits 0.

For OAuth-only introspection:

npx tsx examples/localnet-with-oauth2.ts

Expected outcome: Token preview, getUserStatus() JSON, and getVersion() from the Ledger API.


External signing

External parties follow prepare → sign → execute. Use the utilities referenced from External signing for full narrative; the public entry points are:

  • prepareExternalTransaction
  • executeExternalTransaction
  • allocateExternalParty, createExternalParty, generateExternalPartyTopology

Repository example:

npx tsx examples/external-signing.ts

Expected outcome: Depending on environment, the script walks through topology + signing steps; failures usually surface as ApiError or ValidationError with HTTP details.


Transfer amulets

The standard user-driven path is transfer offer → accept. The SDK wraps both sides:

import { acceptTransferOffer, Canton, createTransferOffer } from '@fairmint/canton-node-sdk';

const canton = new Canton({ network: 'localnet' });

const offerCid = await createTransferOffer({
  ledgerClient: canton.ledger,
  receiverPartyId: 'RECEIVER_PARTY_ID',
  amount: '5',
  description: 'Payroll top-up',
});

await acceptTransferOffer({
  ledgerClient: canton.ledger,
  transferOfferContractId: offerCid,
  acceptingPartyId: 'RECEIVER_PARTY_ID',
});

Replace RECEIVER_PARTY_ID with a real party string from your environment.

Expected outcome: Offer contract archives after acceptance; receiver balance updates after ledger commit (timing may require a short poll — see getAmuletsForTransfer in the Reference catalog).

Runnable script:

npx tsx examples/transfer-amulets.ts RECEIVER_PARTY_ID 5

Scan API note

On LocalNet, configure known-good Scan base URLs in CantonConfig.apis — automatic discovery behaves differently than hosted devnets. See resolveScanApiUrls in the Reference catalog when failover matters.