Try it Live
Run Denomination examples in the interactive playground
BrandedEther
Data-first branded Ether type -BrandedUint representing Ether denomination with zero-overhead runtime.
Overview
BrandedEther is a branded BrandedUint (Uint8Array-based) providing compile-time type safety for Ether values with zero-overhead direct data representation.
Type Definition
BrandedUint properties - 32-byte Uint8Array with bigint arithmetic.
Construction
BrandedEther.from(value)
Create BrandedEther from numeric input.
value: bigint | number | string- Value to convert
BrandedEther
Note: Fractional numbers truncate to integer Ether.
BrandedEther.fromWei(wei)
Convert BrandedWei to BrandedEther (divide by 10^18).
wei: BrandedWei- Wei amount
BrandedEther
Formula: ether = wei / 1_000_000_000_000_000_000 (integer division)
BrandedEther.fromGwei(gwei)
Convert BrandedGwei to BrandedEther (divide by 10^9).
gwei: BrandedGwei- Gwei amount
BrandedEther
Formula: ether = gwei / 1_000_000_000 (integer division)
Conversions To Other Units
BrandedEther.toWei(ether)
Convert BrandedEther to BrandedWei (multiply by 10^18).
ether: BrandedEther- Ether amount
BrandedWei
Formula: wei = ether * 1_000_000_000_000_000_000
BrandedEther.toGwei(ether)
Convert BrandedEther to BrandedGwei (multiply by 10^9).
ether: BrandedEther- Ether amount
BrandedGwei
Formula: gwei = ether * 1_000_000_000
Conversions To Base Type
BrandedEther.toU256(ether)
Convert BrandedEther to raw BrandedUint (removes denomination branding).
ether: BrandedEther- Ether amount
BrandedUint
Note: Removes denomination type safety. Use for arithmetic requiring BrandedUint.
Constants
Usage Examples
User Balance Display
Transaction Value
Balance Operations
Conversion Chain
Fractional Display
Type Safety
BrandedEther prevents mixing denominations at compile time:Performance
BrandedEther uses direct Uint8Array representation:- Zero wrapper overhead
- Direct bigint arithmetic
- Optimal for hot paths
- Same memory layout as BrandedUint
Common Ether Values
Integer Division Notes
All conversions to Ether use integer division. Fractional Wei/Gwei amounts truncate:When to Use BrandedEther
Use BrandedEther when:- Type safety is critical
- Working with existing BrandedUint infrastructure
- Building type-safe APIs
- Performance-sensitive balance operations
Related
- BrandedWei - Branded Wei type
- BrandedGwei - Branded Gwei type
- BrandedUint - Underlying branded Uint256 type
- Conversions - Converting between units

