Value
Utility functions for displaying and parsing Ethereum Values as defined under 2.1. Value in the Ethereum Yellow Paper
Examples
import { Value } from 'ox'
const value = Value.fromEther('1')
1_000_000_000_000_000_000n const formattedValue = Value.formatEther(value)
'1' const value = Value.fromEther('1', 'szabo')
1_000_000n
Functions
Name | Description |
---|---|
Value.format | Formats a bigint Value to its string representation (divided by the given exponent). |
Value.formatEther | Formats a bigint Value (default: wei) to a string representation of Ether. |
Value.formatGwei | Formats a bigint Value (default: wei) to a string representation of Gwei. |
Value.from | Parses a string representation of a Value to bigint (multiplied by the given exponent). |
Value.fromEther | Parses a string representation of Ether to a bigint Value (default: wei). |
Value.fromGwei | Parses a string representation of Gwei to a bigint Value (default: wei). |
Errors
Name | Description |
---|---|
Value.InvalidDecimalNumberError | Thrown when a value is not a valid decimal number. |