toUnits

Converts a string representation of a number with decimal places to a BigInt representation.

Example

import { toUnits } from "thirdweb/utils";
toUnits("1", 18);
// 1000000000000000000n
function toUnits(tokens: string, decimals: number): bigint;

Parameters

The string representation of the number, including the integer and fraction parts.

Type

let tokens: string;

The number of decimal places to include in the BigInt representation.

Type

let decimals: number;

Returns

let returnType: bigint;

The BigInt representation of the number.