Skip to main content

EffectiveGasPrice

EIP-1559 effective gas price representing the actual gas price paid for a transaction. Calculated from base fee and effective priority fee, capped by maxFeePerGas.

Overview

Branded bigint type representing effective price in Wei. Determines actual transaction cost: cost = effectiveGasPrice * gasUsed.

Quick Start

Type Definition

Branded bigint preventing confusion with other fee types. All values in Wei.

API

Construction

from(value)

Create from bigint, number, or hex string.

calculate(baseFee, maxFee, maxPriorityFee)

Calculate from EIP-1559 fee parameters.

fromGwei(gwei)

Create from Gwei value.

fromWei(wei)

Create from Wei value (alias for from).

Conversion

toGwei(effectivePrice)

Convert to Gwei.

toWei(effectivePrice)

Convert to Wei (identity).

toNumber(effectivePrice)

Convert to number. Warning: precision loss on large values.

toBigInt(effectivePrice)

Convert to bigint (identity).

Comparison

equals(price1, price2)

Check equality.

compare(price1, price2)

Compare values. Returns -1, 0, or 1.

Calculation Formula

Capped at maxFeePerGas for safety.

Calculation Examples

Within Budget

Priority Fee Capped

Zero Priority Fee

MaxFee Equal to BaseFee

Real-world Examples

Transaction Cost

Receipt Verification

Refund Calculation

Fee Breakdown

Miner vs Burned

Historical Analysis

Track Effective Prices

Compare Networks

Fee Estimation

Predict Effective Price

Common Patterns

Validate Transaction

Cost Comparison

Specification