getEstimatedTrafficCost inspects InteractiveSubmissionPrepareResponse.costEstimation. When absent it returns undefined. Otherwise it aggregates confirmationRequestTrafficCostEstimation, confirmationResponseTrafficCostEstimation, adds UPDATE_CONFIRMATION_OVERHEAD_BYTES, and derives costInCents / costInDollars via calculateTrafficCostInCents / calculateTrafficCostInDollars.
Setup
import { getEstimatedTrafficCost } from '@fairmint/canton-node-sdk';
Minimal example
const prepared = await ledgerClient.interactiveSubmissionPrepare({
commands: COMMAND_ARRAY_PLACEHOLDER,
commandId: 'COMMAND_ID',
userId: 'USER_ID',
actAs: ['PARTY_ID'],
readAs: [],
synchronizerId: 'SYNCHRONIZER_ID',
verboseHashing: false,
packageIdSelectionPreference: [],
});
const estimate = getEstimatedTrafficCost(prepared);
console.log(estimate?.costInDollars);
Parameters
preparedTransaction— RawInteractiveSubmissionPrepareResponseinstance.
Returns
TrafficCostEstimate | undefined — Includes estimatedAt when server timestamps estimation.
Errors
Pure shaping logic — never throws unless malformed numeric coercion fails indirectly.
Auth and party
Not networked — consumes previously retrieved prepare payloads.