Skip to content

parseUnits

parseUnits(value, decimals?): bigint

Defined in: utils/parse-units.ts:30

Parse a decimal string into the smallest unit (e.g. wei) as a bigint, given the number of decimal places.

Similar to “parseUnits” in ethers.js

Similar to “parseUnits” in viem

string

the decimal string to parse

number = 18

the number of decimal places (default 18)

bigint

a bigint in the smallest unit

parseUnits('1', 6)
// 1000000n
parseUnits('1.5', 6)
// 1500000n
parseUnits('1', 18)
// 1000000000000000000n