Canton Node SDK
Quickstart
Install @fairmint/canton-node-sdk, load config, and call Ledger and Validator APIs in a few lines.
Install
npm install @fairmint/canton-node-sdk
Requirements: Node.js ≥ 18. TypeScript recommended.
Choose a client
Unified Canton (typical)
import { Canton } from '@fairmint/canton-node-sdk';
const canton = new Canton({ network: 'localnet' });
const version = await canton.ledger.getVersion();
const balance = await canton.validator.getWalletBalance();
canton.ledger, canton.validator, and canton.scan share auth and config. Use getPartyId / setPartyId when your process acts as different parties. Browse the searchable Reference catalog for unified client rows.
Single client + CantonRuntime
import { CantonRuntime, EnvLoader, LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
const config = EnvLoader.getConfig('LEDGER_JSON_API', {
network: 'devnet',
provider: '5n',
});
const runtime = new CantonRuntime(config);
const ledger = new LedgerJsonApiClient(runtime);
console.log((await ledger.getVersion()).version);
Configure with environment variables
Minimal .env shape (names vary slightly by network — see generated EnvLoader docs in repo):
CANTON_CURRENT_NETWORK=devnet
CANTON_CURRENT_PROVIDER=5n
CANTON_DEVNET_5N_AUTH_URL=https://devnet.5n.canton.com/oauth2/token
CANTON_DEVNET_5N_PARTY_ID=Alice::1220
CANTON_DEVNET_5N_USER_ID=alice
CANTON_DEVNET_5N_LEDGER_JSON_API_URI=https://devnet.5n.canton.com/ledger-json-api
CANTON_DEVNET_5N_LEDGER_JSON_API_CLIENT_ID=…
CANTON_DEVNET_5N_LEDGER_JSON_API_CLIENT_SECRET=…
CANTON_DEVNET_5N_VALIDATOR_API_URI=https://devnet.5n.canton.com/validator-api
CANTON_DEVNET_5N_VALIDATOR_API_CLIENT_ID=…
CANTON_DEVNET_5N_VALIDATOR_API_CLIENT_SECRET=…
The Reference catalog lists CantonConfig-related keywords (managed parties, apis overrides, debug).
Where next
| Goal | Link |
|---|---|
| Task recipes | Guides hub |
| API catalog (searchable) | Reference |
| Runnable scripts | Examples |
| External parties | External signing |
| Local Canton | LocalNet |
| Wiki / long guides | GitHub wiki |
For contribution workflows, see the README.