Skip to main content
Version: 0.96.0

Function: bigIntReplacer()

bigIntReplacer(_key: string, value: unknown): unknown

Defined in: utils.ts:236

JSON replacer function that converts BigInt values to strings.

Parameters

ParameterTypeDescription
_keystringProperty key (unused).
valueunknownValue to transform.

Returns

unknown

String representation if BigInt, otherwise unchanged value.

Example

TypeScript
import { bigIntReplacer } from '@chainlink/ccip-sdk'

const data = { amount: 1000000000000000000n }
const json = JSON.stringify(data, bigIntReplacer)
console.log(json) // '{"amount":"1000000000000000000"}'

See

bigIntReviver - Revive BigInt values when parsing