evm-fees-advisor
evm-fees-advisor is a REST + SSE API for EVM network gas fee estimation. It supports EIP-1559 (Ethereum mainnet, Polygon, BSC) and legacy gasPrice (Ethereum Classic), with per-transaction gas estimation via eth_estimateGas.
Use it when you need to:
- Get accurate
maxFeePerGas+maxPriorityFeefor EIP-1559 transactions - Estimate gas cost per specific contract call
- Predict baseFee worst-case N blocks ahead to avoid stuck transactions
- Recover a stuck transaction with the correct minimum fee bump
- Plan a batch of transactions with deadline constraints
Fee models
EIP-1559 (Ethereum, Polygon, BSC)
{
"feeModel": "eip1559",
"currentBaseFeeGwei": 45.2,
"fast": { "maxPriorityFeeGwei": 2.0, "maxFeePerGasGwei": 100.0, "estimatedWaitBlocks": 1 },
"medium": { "maxPriorityFeeGwei": 1.0, "maxFeePerGasGwei": 70.0, "estimatedWaitBlocks": 3 },
"slow": { "maxPriorityFeeGwei": 0.5, "maxFeePerGasGwei": 55.0, "estimatedWaitBlocks": 6 },
"updatedAt": "..."
}
maxFeePerGas = currentBaseFee × 2 + maxPriorityFee (worst-case for next block).
Legacy gasPrice (Ethereum Classic)
{
"feeModel": "legacy",
"fast": { "gasPriceGwei": 10.0, "estimatedWaitBlocks": 1 },
"medium": { "gasPriceGwei": 6.0, "estimatedWaitBlocks": 3 },
"slow": { "gasPriceGwei": 3.5, "estimatedWaitBlocks": 6 }
}
Endpoints
GET /fees
Current fee tiers (EIP-1559 or legacy format, depending on network).
GET /fee-advisor/next-base-fee?blocks=5 (EIP-1559 only)
BaseFee worst-case prediction for the next N blocks.
Assumes each block is 100% full → baseFee × 1.125 per block. Use worstCaseInNBlocksGwei + tip as your maxFeePerGas to guarantee inclusion within N blocks.
Returns HTTP 400 for legacy networks.
POST /fee-advisor/estimate
Calls eth_estimateGas against the node. Auto-detects transaction type:
data field | Detected type | Gas handling |
|---|---|---|
| empty | eth_transfer | Hardcoded 21,000 gas |
starts with a9059cbb | erc20_transfer | Calls estimateGas |
| other | contract_interaction | Calls estimateGas |
Returns estimatedGas, recommendedGasLimit (+20% buffer), txType, wouldRevert, and fee estimates per tier.
If the transaction would revert → HTTP 422 with ESTIMATE_GAS_FAILED.
POST /fee-advisor/deadline
Fee required to confirm within deadlineSec seconds at targetProbability.
curl -X POST .../fee-advisor/deadline \
-d '{"deadlineSec": 120, "targetProbability": 0.95}'
POST /fee-advisor/stuck-tx
Recovery fee for a stuck EIP-1559 transaction. EVM nodes require minimum +10% on both maxFeePerGas and maxPriorityFee to accept a replacement.
Returns "action": "replace" with new values, or "action": "wait" if current fees are sufficient.
POST /fee-advisor/batch
Batch transaction planner. Same strategies as bitcoin-fees-advisor: minimize_cost, uniform, asap.
GET /fee-advisor/market
Full network state: baseFee, block utilization, pending tx count, priority fee percentiles (p10/p50/p90), baseFee history for last 10 blocks.
GET /fees/stream (SSE)
Real-time fee updates. Throttled to SSE_MIN_INTERVAL_MS (default: 30s). Heartbeat every 25s.
GET /events/stream?txids=0xabc (SSE)
Watch specific EVM transaction hashes: tx.confirmed, tx.replaced.
Network specifics
| Network | Fee model | Notes |
|---|---|---|
| Ethereum mainnet | EIP-1559 | Standard volatility |
| Polygon PoS | EIP-1559 | High baseFee volatility (spikes to 1000+ gwei). Aggressive worst-case in deadline calculations. |
| BSC | EIP-1559 | BaseFee stable (~3 gwei). Priority fee dominates. Response includes a note. |
| Ethereum Classic | Legacy | No baseFee. next-base-fee endpoint returns HTTP 400. |
Billing
- Free - rate-limited requests
- PAYG / requests - per API call
- Subscription / credits - monthly request pool
Next steps
Related reading: EVM Gas Fee Estimation Guide