EVM Gas Fee Estimation: EIP-1559 baseFee, Priority Fees, and Why Fixed gasPrice Breaks
If you're setting gasPrice the same way across Ethereum, Polygon, and BSC, you're going to have problems. EIP-1559 fee mechanics are network-specific, and the right approach for Ethereum mainnet is wrong for Polygon and mostly irrelevant for BSC.
EIP-1559 mechanics (Ethereum mainnet)
EIP-1559 replaced the single gasPrice field with two parameters:
baseFee - set by the protocol, changes every block. Burned (not paid to miners). Every node knows it.
maxPriorityFee (tip) - paid to the validator as an incentive. You set this based on how fast you want inclusion.
maxFeePerGas - your ceiling. Must be ≥ baseFee + maxPriorityFee. Excess over baseFee + tip is refunded.
The rule: if maxFeePerGas < baseFee, your transaction sits in the pool and doesn't get mined. This is the most common cause of stuck EIP-1559 transactions.
BaseFee adjustment formula
BaseFee changes every block based on the previous block's fullness. The formula:
- Block 100% full:
nextBaseFee = currentBaseFee × 1.125 - Block 50% full (target):
nextBaseFee = currentBaseFee(unchanged) - Block 0% full:
nextBaseFee = currentBaseFee × 0.875
Worst-case over N blocks (all blocks 100% full):
worstCaseBaseFee = currentBaseFee × 1.125^N
This is the number you use for maxFeePerGas planning when you want to guarantee inclusion within N blocks regardless of congestion.
# Get baseFee prediction for next 5 blocks
curl "https://api.overblock.io/evm-fees/fee-advisor/next-base-fee?blocks=5" \
-H "X-API-Key: your-token"
{
"currentBaseFeeGwei": 45.2,
"worstCaseIn5BlocksGwei": 81.3,
"predictions": [
{ "block": "+1", "baseFeeGwei": 50.8 },
{ "block": "+2", "baseFeeGwei": 57.1 }
]
}
Polygon: high volatility, fast blocks
Polygon uses EIP-1559 but with significantly more volatile baseFee. Spikes to 500-1000+ gwei during periods of high activity are common. Blocks arrive every ~2 seconds.
For Polygon, use more aggressive worst-case calculations. The evm-fees-advisor applies POLYGON_HIGH_VOLATILITY=true by default, which uses a larger multiplier in deadline calculations.
Don't use Ethereum mainnet fee estimates for Polygon transactions - the price ranges are completely different.
BSC: EIP-1559 in name only
BSC implements EIP-1559 but the baseFee is effectively fixed at ~3 gwei. In practice, BSC fee estimation behaves more like legacy gasPrice - set gasPrice high enough above 3 gwei and your transaction will be included.
The evm-fees-advisor detects BSC (chain ID 56) and includes a note in the response: "BSC baseFee is stable (~3 gwei). Priority fee dominates."
eth_estimateGas: when to use it
For ETH transfers: hardcode 21,000 gas. Every EVM node returns 21,000. Don't call eth_estimateGas.
For ERC-20 transfers: roughly 65,000 gas, but varies. Call eth_estimateGas.
For arbitrary contract calls: gas usage depends on contract state at execution time. Call eth_estimateGas close to submission time. Add a 20% buffer (gasLimit = estimatedGas × 1.2) to handle minor variance.
curl -X POST .../fee-advisor/estimate \
-H "X-API-Key: your-token" \
-d '{"from":"0x...","to":"0x...","data":"0xa9059cbb..."}'
{
"estimatedGas": 65000,
"recommendedGasLimit": 78000,
"txType": "erc20_transfer",
"wouldRevert": false
}
If wouldRevert: true, your transaction will fail. Fix the call parameters before submitting.
Recovering a stuck transaction
EVM nodes require a minimum +10% on both maxFeePerGas and maxPriorityFee to accept a replacement transaction (unlike Bitcoin's BIP125 which only requires +1 sat/vB).
curl -X POST .../fee-advisor/stuck-tx \
-d '{"currentMaxFeePerGasGwei": 40, "currentMaxPriorityFeeGwei": 1, "targetBlocks": 1}'
The response tells you whether to replace (with exact new values) or wait (if current fees are already competitive).
evm-fees-advisor covers all of this - EIP-1559 and legacy, all networks, per-transaction estimation - as a REST + SSE API.