EIP-3416 Median gas premium
No call decision · Fees & gas · EIP status Stagnant · created 2021-03-18
A gas fee scheme where the user sets only a single maximum willingness to pay (fee cap), and the actual fee is determined by the weighted median of the priority fees of the transactions included in the block.
Why it is needed
Today, transaction fees work as a first price auction where the sender pays exactly the value they set, so prices spike and crash minute to minute, and wallets frequently overpay even with complex estimation algorithms. The social cost of the network processing one full block does not become 200 times larger just because the gas price jumps from 1 nanogwei to 200 nanogwei, yet the current scheme reflects this inefficiency directly. In addition, because the block gas limit is fixed, transactions can be delayed for multiple blocks when demand spikes, which is unnecessary waiting that benefits no one. EIP-1559 also adjusts the base fee gradually but does not fully address the volatility of the priority fee (tip) itself.
What changes
Today
- Users must guess and set gasPrice or base fee plus tip themselves
- Transaction fees swing sharply minute to minute
- An accepted transaction pays exactly the value the sender set (first price auction)
- Miners pack in transactions with the highest fees first, making it hard to estimate a fair price
After EIP-3416
- The user specifies only a single fee cap (maximum willingness to pay)
- The actual price paid is set by the weighted median of the transactions in the block, usually lower than the fee cap
- The base fee adjusts gradually, by at most 1/8 per block, based on block gas usage
- The top 5% of outliers are excluded from the median calculation for manipulation resistance
Who is affected
- Ordinary users: The burden of fee estimation is reduced, and most users pay less than the maximum they set.
- Wallet developers: This can be simplified to a UX where only a single fee cap value is entered.
- Miners and validators: Transactions can still be included in order of largest fee cap, but additional logic is needed to compute the weighted median.
- The whole network: No new field is added to the transaction format, so existing signing and encoding methods remain unchanged.
In depth
How BASE_FEE adjusts
GAS_DELTA is computed as (PARENT_GAS_USED - PARENT_GAS_TARGET) / PARENT_GAS_TARGET, and BASE_FEE is updated every block as BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE (1/8). INITIAL_BASE_FEE at FORK_BLOCK_NUMBER is set to the median gas price of the immediately preceding block. The key difference from EIP-1559-style schemes is that this one is additive rather than multiplicative.
Transaction encoding and FEE_CAP
Transactions keep the existing format rlp([nonce, gasPrice, gasLimit, to, value, data, v, r, s]), with the gasPrice field now serving as FEE_CAP. From this, GAS_PREMIUM = (FEE_CAP - BASE_FEE) / 2 is derived. If FEE_CAP is less than BASE_FEE, the transaction is invalid in that block but may still be included in a later block.
Computing the weighted median GASPRICE
For every transaction tx_i included in the block, GASPRICE = BASE_FEE + median((tx_i.gasPrice - BASE_FEE) / 2) is computed. Each unit of gas is ordered by the value BASE_FEE + tx.gasPrice/2, weighted by gas consumed, and the median is taken as the value that bisects the lower 95% range after excluding the top 5% of outliers.
Payment and refund
tx.origin first pays GASPRICE * tx.gasLimit, then is refunded GASPRICE * (tx.gasLimit - gasUsed), the remainder after subtracting the gasUsed during execution. Every transaction in the block pays the same GASPRICE regardless of the FEE_CAP it specified.
The miner's greedy inclusion strategy
Because FEE_CAP and GAS_PREMIUM have a positive linear relationship, miners can keep using the same greedy strategy of including the transactions with the largest FEE_CAP first. This means the way blocks are filled does not change much.
Why an additive BASE_FEE was chosen
The multiplicative version (PARENT_BASE_FEE * GAS_DELTA * BASE_FEE_MAX_CHANGE) was found vulnerable in simulations to an attack where senders drive fees toward zero. With an additive scheme, the fee-optimal strategy for a batch of non-urgent transactions is to spread them across multiple blocks, which lowers congestion and price volatility, whereas under the multiplicative scheme the opposite, sending everything at once, becomes advantageous and encourages spikes.
Why the top 5% of outliers are excluded
Over the past six months, block utilization has been around 97%, leaving only about 3% typically empty, so even if a miner tries to fill that empty space with fake transactions to push up the median, exceeding 5% would require crowding out other profitable transactions. This limits the effectiveness of manipulation, and the median remains a statistic that is robust to manipulation.
Status and compatibility
Since no new field is added to the transaction, there is no impact on wallets, and only the price calculation logic for miners and validators becomes somewhat more complex. FORK_BLOCK_NUMBER remains TBD and Test Cases also remain TBD, and this EIP's current status is marked Stagnant, so there is no concrete inclusion timeline or fork decision yet.