Skip to content

Reference

getPaidTrafficCostFromCompletion

Safely read paidTrafficCost from Ledger completion payloads as bigint without double precision loss.

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 — Ledger Completion object 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.

See also

Source

src/utils/traffic/paid-traffic-cost.ts