Skip to content

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

NameDescription
Value.formatFormats a bigint Value to its string representation (divided by the given exponent).
Value.formatEtherFormats a bigint Value (default: wei) to a string representation of Ether.
Value.formatGweiFormats a bigint Value (default: wei) to a string representation of Gwei.
Value.fromParses a string representation of a Value to bigint (multiplied by the given exponent).
Value.fromEtherParses a string representation of Ether to a bigint Value (default: wei).
Value.fromGweiParses a string representation of Gwei to a bigint Value (default: wei).

Errors

NameDescription
Value.InvalidDecimalNumberErrorThrown when a value is not a valid decimal number.