Try it Live
Run Denomination examples in the interactive playground
Denomination
Type-safe Ethereum value denominations with compile-time unit tracking.Overview
Branded types representing Ethereum denominations. Wei is a brandedbigint (whole numbers only). Ether and Gwei are branded string types that support decimal values like "1.5". Each denomination prevents accidental unit mixing at compile time while enabling seamless conversions.
Quick Start
- Direct Usage
- Gas Price Calculation
- Transaction Values
Types
Each denomination uses branded types for compile-time safety:- Wei
- Gwei
- Ether
Conversion Constants
Interactive Converter
Try converting between denominations:- Wei ↔ Gwei ↔ Ether
- Common Values
- Gas Price Reference
Denomination Table
| Unit | Wei | Gwei | Ether | Common Use |
|---|---|---|---|---|
| Wei | 1 | 10^-9 | 10^-18 | Precise calculations, smallest unit |
| Gwei | 10^9 | 1 | 10^-9 | Gas prices, transaction fees |
| Ether | 10^18 | 10^9 | 1 | User-facing values, balances |
API Variants
Two APIs for different use cases:Branded API (Type-safe)
Requires branded types, compile-time safety:API Documentation
Wei
Smallest denomination for precise calculations and internal representation. View Wei →Gwei
Gas price denomination, 1 billion Wei. View Gwei →Ether
User-facing denomination, 1 quintillion Wei. View Ether →BrandedWei
Type-safe Wei with BrandedUint data representation. View BrandedWei →BrandedGwei
Type-safe Gwei with BrandedUint data representation. View BrandedGwei →BrandedEther
Type-safe Ether with BrandedUint data representation. View BrandedEther →Conversions
Converting between Wei, Gwei, and Ether with type safety. View Conversions →WASM Implementation
WebAssembly-accelerated conversions compiled from Zig. View WASM →Usage Patterns
Common patterns for gas calculations, transaction values, and conversions. View Usage Patterns →Gas Calculator
Calculate transaction costs and convert between denominations and USD. View Gas Calculator →Scale Visualization
Visual guides to understanding denomination relationships and magnitudes. View Scale Visualization →Type Safety
Each denomination prevents accidental mixing:Decimal Precision
Ether and Gwei use decimal strings to preserve fractional values:Related Types
- Denomination (Effect) - Effect.ts integration with Schema validation

