CantonRuntime holds the mutable effective ClientConfig (including merged env defaults), the shared Map of AuthenticationManager instances, and the resolved logger. Every LedgerJsonApiClient, ValidatorApiClient, and ScanApiClient receives the same runtime instance so tokens and HTTP behavior stay aligned.
You access it as canton.runtime from Canton, or via BaseClient.getRuntime() when writing extensions.
import type { CantonRuntime } from '@fairmint/canton-node-sdk';
Example — fork with debug logger
import { Canton, ConsoleLogger, LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
const canton = new Canton({
network: 'localnet',
});
const debugRuntime = canton.runtime.fork({
debug: true,
logger: new ConsoleLogger({ logLevel: 'debug' }),
});
const altLedger = new LedgerJsonApiClient(debugRuntime);
await altLedger.getVersion();
Prefer the original canton.ledger unless you intentionally split configuration for tests or parallel identities.
Methods and properties
constructor(config, authManagers?)— Copiesconfig, fills default logger viacreateLogger(FileLogger, orCompositeLogger+ConsoleLoggerwhen debug), optionally reuses an existing auth-manager map (used byfork).fork(overrides)— Returns a newCantonRuntimewith shallow-mergedClientConfig, mergedapismaps, shared sameauthManagersmap — sessions stay unified across forks.createClientConfig(apiType)— Returns aClientConfigview containing only the resolvedapis[apiType]entry plus top-level fields. On first access for an API, callsEnvLoader.getConfigif that API was not explicitly configured, then merges provider/party/user/managedParties/authUrl ontobaseConfigas side effects.getAuthenticationManager(authUrl, authConfig)— Returns cachedAuthenticationManageror constructs one.getNetwork()/getProvider()/getLogger()— Read merged base configuration.
Errors and pitfalls
- Side effects on resolve: First resolution of an API mutates
baseConfig(fills missing provider, auth URL, party id, user id, managed parties from env). Order of client construction can therefore matter for what gets merged. forklogger: Ifoverrides.loggeris omitted, the fork keeps the parent logger explicitly.
See also
- BaseClient — consumes
createClientConfigoutput. - AuthenticationManager — cached inside the runtime.
- EnvLoader — env-backed defaults during resolution.
Source
src/core/runtime/CantonRuntime.ts on GitHub.