Skip to main content

Overview

FeeOracle provides real-time gas price estimation for Ethereum transactions. It fetches current network fee data, estimates EIP-1559 fees with configurable priority levels, and supports watching for fee updates.

API

Factory

Creates a FeeOracle instance bound to a provider. Options:

getFeeData

Fetch current network fee data.
Returns: Promise<FeeDataType>

estimateEip1559Fees

Estimate fees for an EIP-1559 transaction with configurable priority.
Options: Priority multipliers:
  • low: 0.8x priority fee
  • medium: 1.0x priority fee
  • high: 1.5x priority fee
Returns: Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>

watchFees

Subscribe to fee updates with polling.
Options: Returns: () => void - Unsubscribe function

Types

FeeDataType

FeeEstimateOptions

FeeOracleOptions

Examples

Transaction with Dynamic Fees

Fee Display UI

Legacy Chain Support

FeeOracle handles chains without EIP-1559 support gracefully:

Custom Fee History Analysis

How It Works

FeeOracle uses three JSON-RPC methods:
  1. eth_gasPrice - Gets the legacy gas price
  2. eth_getBlockByNumber - Fetches the latest block for base fee and blob fee
  3. eth_feeHistory - Analyzes recent blocks for priority fee estimation
The maxFeePerGas is calculated as baseFee * 2 + priorityFee, providing a buffer for base fee increases across blocks.

See Also