Skip to main content

Try it Live

Run Denomination examples in the interactive playground

Gwei

Ethereum gas price denomination, equal to 1 billion (10^9) Wei.

Overview

Gwei (gigawei) is the standard unit for gas prices and transaction fees. Gwei.Type is a branded Uint256 preventing accidental unit mixing. Common usage: Gas prices, transaction fees, network congestion pricing.

Type Definition

Construction

Gwei.from(value)

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

Conversions From Other Units

Gwei.fromWei(wei)

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

Gwei.fromEther(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/Gwei.ts:19

Conversions To Other Units

Gwei.toWei(gwei)

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

Gwei.toEther(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/Gwei.ts:29

Conversions To Base Type

Gwei.toU256(gwei)

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

Usage Examples

Gas Price Calculations

EIP-1559 Transaction

Gas Price Comparison

Gas Price Tracking

Conversion Constants

Common Gwei Values

Type Safety

Gwei type prevents mixing with other denominations:

Display Formatting

Gwei is human-readable for gas prices:

WASM Acceleration

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