Estimating EIP-1559 Base Fee from Recent Blocks with eth_getBlockByNumber
Bottom line: The next block’s base fee is a pure integer function of the parent block’s gasUsed and baseFeePerGas — you can recompute it yourself from one eth_getBlockByNumber call and verify the result against the next block before you sign anything.
The EIP-1559 base fee is not a market outcome, an oracle input, or a validator decision. It is deterministic arithmetic defined in the EIP, with a hard cap of ±12.5% movement per block. If you can read the parent block header, you can predict the next base fee exactly, down to the wei. That matters when you are building transaction submission logic, debugging a stuck transaction, or writing a fee estimator that you actually trust. This post walks through the formula as it appears in the EIP, implements it in a couple of languages, and validates the prediction against live RPC data.
Not investment advice. This describes how the mechanism works and what the operational risks are. It does not tell you what to buy. See the editorial policy.
The formula, exactly as specified
EIP-1559 defines a BASE_FEE_MAX_CHANGE_DENOMINATOR of 8 and an ELASTICITY_MULTIPLIER of 2. The gas target of a block is its gas limit divided by the elasticity multiplier — so on mainnet, with a 30,000,000 gas limit, the target is 15,000,000 gas. The base fee adjusts toward that target every block:
- If
parentGasUsed == parentGasTarget, the base fee is unchanged. - If
parentGasUsed > parentGasTarget, the base fee increases byparentBaseFee * (parentGasUsed - parentGasTarget) / parentGasTarget / 8. - If
parentGasUsed < parentGasTarget, the base fee decreases by the same expression, floored at zero.
The integer division matters. The EIP spec truncates toward zero at each step, and clients implement it that way. If you compute in floating point you will drift by a wei or two, which is usually harmless for a human but not for a test that asserts equality.
The 12.5% bound falls out of the formula: the maximum parentGasUsed is the full block gas limit, which is twice the target, so the maximum numerator is parentGasTarget, giving parentBaseFee / 8 as the largest possible increase. A completely empty block gives the largest possible decrease, also parentBaseFee / 8.
Pulling the parent block over JSON-RPC
You only need two fields from the parent header: gasUsed and baseFeePerGas. Both are hex-encoded quantities. eth_getBlockByNumber with false for the full-transactions flag is the cheapest call.
1 | curl -s -X POST https://your-rpc-endpoint.example \ |
Sample output shape (values will differ):
1 | { |
0x1c9c380 is 30,000,000 — the current mainnet gas limit. 0x6fc23ac00 is 30,000,000,000 wei, or 30 gwei. gasUsed of 0xe4e1c0 is 15,000,000, which happens to equal the target exactly, so the next base fee would be identical.
Two operational notes. First, latest is a moving target; if you need to reason about a specific block, pin the block number. Second, some providers serve latest from a load-balanced pool with slightly different head heights. If you are validating a prediction, fetch the parent by explicit block number and then fetch the child by parentNumber + 1.
Implementing the calculation
Here is the formula in Python, using only integers. It takes the parent’s gasUsed, gasLimit, and baseFeePerGas and returns the next block’s base fee in wei.
1 | BASE_FEE_MAX_CHANGE_DENOMINATOR = 8 |
The max(..., 1) on the increase path is not in the EIP prose but is in the reference implementations: when a block is even one gas over target, the base fee must go up by at least 1 wei, otherwise an extremely low base fee could stall. The decrease path has no such floor — it can go to zero, and on a chain that has been idle long enough it will.
The same logic in JavaScript, if you are doing this in a browser or a Node service:
1 | const DENOM = 8n; |
Use BigInt throughout. Base fees on mainnet are comfortably within Number.MAX_SAFE_INTEGER today, but the intermediate product parentBaseFee * delta can exceed it once base fees get into the tens of gwei and deltas are large. Silent precision loss in a fee estimator is a bad failure mode.
Validating the prediction against live data
The whole point of recomputing the formula is to catch cases where your assumptions are wrong — a different chain, a different gas limit, a fork that changed the constants. Fetch two consecutive blocks and compare.
1 |
|
Feed the first line into the Python function above and compare with the second line. On mainnet you should get an exact match every time. If you do not, the most likely causes are (a) you fetched the parent from one provider and the child from another with a different head, or (b) you are on a chain that has overridden the constants — some L2s and testnets do.
A quick sanity check on the bound: take the parent’s base fee, multiply by 1.125, and confirm the child’s base fee is at or below that. Multiply by 0.875 and confirm the child is at or above it. If either check fails, something is wrong with your inputs, not with the protocol.
What the numbers look like in practice
Here is a table of representative parent-block states and the resulting next-block base fee, computed with the formula above. The parent base fee is 30 gwei in all rows, and the gas limit is 30,000,000.
| Parent gasUsed | % of target (15M) | Direction | Next base fee (gwei) | Change |
|---|---|---|---|---|
| 0 | 0% | down | 26.25 | −12.5% |
| 7,500,000 | 50% | down | 28.125 | −6.25% |
| 15,000,000 | 100% | flat | 30.0 | 0% |
| 22,500,000 | 150% | up | 31.875 | +6.25% |
| 30,000,000 | 200% | up | 33.75 | +12.5% |
The symmetry is the useful part. A block that is completely full pushes the base fee up by exactly the same absolute amount that an empty block pushes it down. There is no asymmetry penalty for sustained congestion beyond the compounding of the 12.5% steps — which, over several consecutive full blocks, is substantial: 30 gwei becomes roughly 33.75, then 37.97, then 42.72, and so on. That compounding is why fee spikes resolve quickly once blocks empty out.
Pitfalls and how to diagnose them
Floating-point drift. If your predicted base fee is off by 1–3 wei, you are almost certainly using floats. The EIP specifies integer division. Diagnose by logging the intermediate base_fee_delta and comparing against a BigInt implementation.
Fetching parent and child from different heads. Load-balanced RPC providers can serve latest at different heights within a few hundred milliseconds of each other. Symptom: intermittent mismatches that resolve on retry. Fix: pin block numbers explicitly, or use a single provider for the pair.
Assuming a 30M gas limit. The gas limit is set by validators and drifts slowly. It has been 30,000,000 on mainnet for a long time, but it is not a constant. Always read gasLimit from the parent header rather than hardcoding it. On L2s and testnets the limit is frequently different.
Assuming the mainnet constants. ELASTICITY_MULTIPLIER and BASE_FEE_MAX_CHANGE_DENOMINATOR are part of the chain’s genesis or fork configuration. Some chains have changed them. If your prediction is consistently off by a fixed ratio, check the chain’s config before assuming a bug in your code.
Confusing base fee with total fee. The base fee is what gets burned. Your transaction also pays a priority fee to the validator, and your maxFeePerGas must cover both. A prediction of the next base fee tells you the minimum you must set maxFeePerGas to for inclusion in that block; it says nothing about what priority fee will actually get you included.
Ignoring the burn. The base fee is destroyed, not paid to anyone. If you are reconciling balances or doing accounting, the base fee component of every transaction is a permanent outflow with no counterparty. That has tax and bookkeeping implications that vary by jurisdiction.
Stale latest after a reorg. A one-block reorg can change the parent you fetched. If you are building anything that submits a transaction based on a computed fee, re-fetch immediately before signing rather than caching the prediction.
FAQ
Why is the maximum base fee change 12.5% per block?
Because the formula divides the deviation from target by the target and then by 8, and the maximum deviation is one full target (a completely full block is twice the target). That gives parentBaseFee / 8, which is 12.5%. The bound is a deliberate design choice to keep fees predictable enough for wallets to auto-set them.
Does the base fee go to the validator?
No. The base fee is burned. Validators receive only the priority fee. This is a core part of the EIP-1559 design and the reason ETH supply dynamics changed after activation.
Can I predict the base fee more than one block ahead?
Only conditionally. You can compute the next block’s base fee exactly from the current block. For block N+2 you need to assume a gasUsed for block N+1, so you get a range rather than a point. The ±12.5% bound lets you compute the worst-case envelope for several blocks out, which is usually what you want for setting a maxFeePerGas that will not expire.
Why does my computed value differ by a few wei from what the node reports?
Integer division order. The EIP truncates at each division step. If you combine the divisions or use floating point, you will be off by a small amount. Use BigInt or Python integers and follow the operation order in the reference implementation.
What happens if a block uses exactly the target gas?
The base fee is unchanged. This is the equilibrium state, and on mainnet it happens often enough that you will see consecutive blocks with identical base fees.
Does this formula apply to L2s?
Usually, with caveats. Most optimistic rollups and several other L2s implement EIP-1559 on their execution layer with the same formula, but the gas limit, elasticity multiplier, and the relationship between L2 gas and L1 data costs differ. Always read the chain’s configuration rather than assuming mainnet constants, and validate against two consecutive blocks before trusting a prediction.








