Skip to main content
Version: 11.x

Function: toBigInt()

toBigInt(value): bigint

Defined in: src/utils/num.ts:49

Convert BigNumberish to bigint

'0x', which holds no digit, is refused with its own message rather than with BigInt's.

Parameters​

value​

BigNumberish

value to convert

Returns​

bigint

converted value

Throws​

when the value is '0x', or anything else BigInt cannot read

Example​

const str = '123';
const result = toBigInt(str);
// result = 123n
toBigInt('0x');
// throws Error("Invalid input: '0x' holds no hexadecimal digit")