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
| Option | Type | Default | Description |
|---|---|---|---|
provider | EIP-1193 Provider | required | JSON-RPC provider with request method |
priorityFeePercentile | number | 50 | Percentile for priority fee calculation from fee history |
historyBlocks | number | 4 | Number of blocks to analyze for priority fee estimation |
getFeeData
Fetch current network fee data.Promise<FeeDataType>
estimateEip1559Fees
Estimate fees for an EIP-1559 transaction with configurable priority.| Option | Type | Default | Description |
|---|---|---|---|
priority | 'low' | 'medium' | 'high' | 'medium' | Transaction priority level |
baseFeeMultiplier | number | 1.25 | Buffer multiplier for base fee increases |
low: 0.8x priority feemedium: 1.0x priority feehigh: 1.5x priority fee
Promise<{ maxFeePerGas: bigint; maxPriorityFeePerGas: bigint }>
watchFees
Subscribe to fee updates with polling.| Option | Type | Default | Description |
|---|---|---|---|
pollingInterval | number | 12000 | Poll interval in milliseconds |
signal | AbortSignal | - | Signal for cancellation |
() => 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:- eth_gasPrice - Gets the legacy gas price
- eth_getBlockByNumber - Fetches the latest block for base fee and blob fee
- eth_feeHistory - Analyzes recent blocks for priority fee estimation
maxFeePerGas is calculated as baseFee * 2 + priorityFee, providing a buffer for base fee increases across blocks.
See Also
- Transaction - Transaction construction
- FeeMarket - EIP-1559 fee market calculations
- GasConstants - Gas cost constants

