Fee Methods
Theeth namespace provides 4 methods for querying gas prices and fee history to estimate transaction costs.
Overview
Access fee methods directly on the provider:Usage Patterns
Estimate Transaction Costs
Calculate gas costs for legacy transactions:Calculate EIP-1559 Fees
Build EIP-1559 transaction fees with historical data:Monitor Gas Prices
Track fee trends over time:Methods
eth_gasPrice
Get current gas price in wei.Quantity.
Use Case: Legacy (non-EIP-1559) transaction fee estimation.
eth_maxPriorityFeePerGas
Get current max priority fee per gas (EIP-1559).Quantity.
Use Case: EIP-1559 transaction fee calculation. This is the “tip” paid to validators.
eth_feeHistory
Get historical gas fee data for a range of blocks.blockCount: Quantity- Number of blocks to query (max varies by node)newestBlock: BlockTag | Quantity- Highest block to queryrewardPercentiles?: number[]- Priority fee percentiles (0-100)
FeeHistory object containing:
oldestBlock: Quantity- First block in rangebaseFeePerGas: Quantity[]- Base fee per blockgasUsedRatio: number[]- Fraction of gas limit usedreward?: Quantity[][]- Priority fees at requested percentiles
eth_blobBaseFee
Get current blob base fee for EIP-4844 transactions.Quantity.
Use Case: Calculate costs for EIP-4844 blob transactions. Blob fees are separate from execution gas fees.
This method is only available on networks that have activated EIP-4844 (Cancun upgrade). It will error on pre-Cancun networks.
Related Methods
- eth_getBlockByNumber - Get block with base fee
- eth_estimateGas - Estimate gas limit
- eth_sendTransaction - Send transaction with fees

