estimateTrafficCost generates a commandId, forwards interactiveSubmissionPrepare with merged defaults (userId / actAs fall back to ledger client configuration), then delegates fee shaping to getEstimatedTrafficCost.
Requires userId (explicit or configured on LedgerJsonApiClient) and actAs parties.
Setup
import { Canton, estimateTrafficCost } from '@fairmint/canton-node-sdk';
const canton = new Canton({
network: 'NETWORK_NAME',
partyId: 'PARTY_ID',
});
Minimal example
const estimate = await estimateTrafficCost({
ledgerClient: canton.ledger,
commands: COMMAND_ARRAY_PLACEHOLDER,
synchronizerId: 'SYNCHRONIZER_ID',
});
console.log(estimate?.totalCostWithOverhead, estimate?.costInDollars);
Parameters
EstimateTrafficCostOptions:
ledgerClient(required) — SuppliesinteractiveSubmissionPrepare.commands(required) — SameCreateCommand/ExerciseCommandinputs as interactive submission.synchronizerId(required) — Domain ID hosting the commands.actAs,readAs,userId,disclosedContracts,packageIdSelectionPreference— Forwarded verbatim after defaults merge.
Returns
Promise<TrafficCostEstimate | undefined> — undefined when costEstimation absent from prepare response.
Errors
Throws Error when userId or actAs cannot be resolved.
Auth and party
Uses authenticated ledger credentials suitable for interactiveSubmissionPrepare.