Skip to main content

Try it Live

Run Denomination examples in the interactive playground

Ether

Primary user-facing Ethereum denomination, equal to 1 quintillion (10^18) Wei.

Overview

Ether (ETH) is the native cryptocurrency of Ethereum. Ether.Type is a branded Uint256 preventing accidental unit mixing. Common usage: Account balances, transaction values, user-facing amounts.

Type Definition

Construction

Ether.from(value)

Create Ether from numeric value.
Parameters:
  • value: bigint | number | string - Value to convert to Ether
Returns: Ether.Type Note: Uses Uint.from internally for conversion. Defined in: primitives/Denomination/Ether.ts:10

Conversions From Other Units

Ether.fromWei(wei)

Convert Wei to Ether (divide by 10^18).
Parameters:
  • wei: Wei.Type - Wei value
Returns: Ether.Type Formula: ether = wei / 1_000_000_000_000_000_000 (integer division) Defined in: primitives/Denomination/Ether.ts:14

Ether.fromGwei(gwei)

Convert Gwei to Ether (divide by 10^9).
Parameters:
  • gwei: Gwei.Type - Gwei value
Returns: Ether.Type Formula: ether = gwei / 1_000_000_000 (integer division) Defined in: primitives/Denomination/Ether.ts:19

Conversions To Other Units

Ether.toWei(ether)

Convert Ether to Wei (multiply by 10^18).
Parameters:
  • ether: Ether.Type - Ether value
Returns: Wei.Type Formula: wei = ether * 1_000_000_000_000_000_000 Defined in: primitives/Denomination/Ether.ts:24

Ether.toGwei(ether)

Convert Ether to Gwei (multiply by 10^9).
Parameters:
  • ether: Ether.Type - Ether value
Returns: Gwei.Type Formula: gwei = ether * 1_000_000_000 Defined in: primitives/Denomination/Ether.ts:29

Conversions To Base Type

Ether.toU256(ether)

Convert Ether to raw Uint256 (removes branding).
Parameters:
  • ether: Ether.Type - Ether value
Returns: Uint.Type Note: Removes type safety. Use for arithmetic operations requiring Uint.Type. Defined in: primitives/Denomination/Ether.ts:34

Usage Examples

Account Balance

Transaction Value

Balance Comparison

Total Value Calculation

Fractional Ether Display

Conversion Constants

Common Ether Values

Type Safety

Ether type prevents mixing with other denominations:

Precision Considerations

Ether uses integer arithmetic. For fractional Ether:
Recommendation: Store all values in Wei, display in Ether.

Display Best Practices

WASM Acceleration

Ether conversions available in WebAssembly for performance:
See WASM for details.