getPaidTrafficCostFromCompletion inspects completion.value.paidTrafficCost:
- Safe integers return
BigInt(number). - Decimal digit strings parse with
BigInt(string). - Any other encoding returns
undefined.
Use on completion stream events or blocking completion queries when reconciling Canton traffic billing.
Setup
import { getPaidTrafficCostFromCompletion } from '@fairmint/canton-node-sdk';
Minimal example
const paid = getPaidTrafficCostFromCompletion(completion);
if (paid !== undefined) {
console.log(paid.toString());
}
Parameters
completion— LedgerCompletionobject from JSON API streams.
Returns
bigint | undefined.
Errors
Never throws — invalid shapes become undefined.
Auth and party
Pure parser; call from whatever worker already authenticated to the completions feed.