Ethereum icon

Ethereum

Interact with Ethereum blockchain

Utils → Parse Units

AI-generated

Summary

Parse a decimal value using a specified number of units.

Inputs

  • decimals — Number of decimals (18 for ETH)
  • value (required) — Decimal value (e.g., "1.5")

Output shape

a string

Returns the parsed numeric representation of the input value as a string; errors are propagated as failures.

Examples

Example 1: Convert 1.5 ETH to its raw unit representation

value=1.5, decimals=18

Example 2: Parse a token amount with 6 decimal places

value=1234.56, decimals=6

Example 3: Parse a whole number with no decimal places

value=42, decimals=0

Links

Discussion