Try it Live
Run Denomination examples in the interactive playground
Wei
Smallest Ethereum denomination (10^-18 Ether) for precise value calculations.Overview
Wei is the atomic unit of Ether. All Ethereum values are ultimately represented in Wei internally.Wei.Type is a branded Uint256 preventing accidental unit mixing.
Type Definition
Construction
Wei.from(value)
Create Wei from numeric value.
value: bigint | number | string- Value to convert to Wei
Wei.Type
Note: Uses Uint.from internally for conversion.
Defined in: primitives/Denomination/Wei.ts:10
Conversions From Other Units
Wei.fromGwei(gwei)
Convert Gwei to Wei (multiply by 10^9).
gwei: Gwei.Type- Gwei value
Wei.Type
Formula: wei = gwei * 1_000_000_000
Defined in: primitives/Denomination/Wei.ts:14
Wei.fromEther(ether)
Convert Ether to Wei (multiply by 10^18).
ether: Ether.Type- Ether value
Wei.Type
Formula: wei = ether * 1_000_000_000_000_000_000
Defined in: primitives/Denomination/Wei.ts:19
Conversions To Other Units
Wei.toGwei(wei)
Convert Wei to Gwei (divide by 10^9).
wei: Wei.Type- Wei value
Gwei.Type
Formula: gwei = wei / 1_000_000_000 (integer division)
Defined in: primitives/Denomination/Wei.ts:24
Wei.toEther(wei)
Convert Wei to Ether (divide by 10^18).
wei: Wei.Type- Wei value
Ether.Type
Formula: ether = wei / 1_000_000_000_000_000_000 (integer division)
Defined in: primitives/Denomination/Wei.ts:29
Conversions To Base Type
Wei.toU256(wei)
Convert Wei to raw Uint256 (removes branding).
wei: Wei.Type- Wei value
Uint.Type
Note: Removes type safety. Use for arithmetic operations requiring Uint.Type.
Defined in: primitives/Denomination/Wei.ts:34
Usage Examples
Gas Cost Calculation
Transaction Value
Precise Accounting
Conversion Constants
Common Wei Values
Type Safety
Wei type prevents mixing with other denominations:WASM Acceleration
Wei conversions available in WebAssembly for performance:Related
- Gwei - Gas price denomination
- Ether - User-facing denomination
- Conversions - Converting between units
- Uint256 - Underlying numeric type

