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
Parameters
value
string
the decimal string to parse
decimals
number = 18
the number of decimal places (default 18)
Returns
bigint
a bigint in the smallest unit
Examples
parseUnits('1', 6)// 1000000nparseUnits('1.5', 6)// 1500000nparseUnits('1', 18)// 1000000000000000000n