{"eip":3416,"title":"Median Gas Premium","description":"A transaction pricing mechanism with a fixed-per-block network fee and a median inclusion fee with additive updates.","authors":["HexZorro (@hexzorro)","Mojtaba Tefagh (@mtefagh)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2021-03-18","discussionsTo":"https://ethereum-magicians.org/t/eip-3416-median-gas-premium/5755","repo":"EIPs","label":"EIP-3416","officialUrl":"https://eips.ethereum.org/EIPS/eip-3416","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3416.md","url":"https://eips.huatuo.xyz/eip-3416/","tldr":{"en":"A stagnant alternative to EIP-1559 in which everyone in a block pays the base fee plus a gas-weighted median premium, aiming to smooth fee spikes without new transaction fields.","ja":"EIP-1559 に代わる停滞中の案。ブロック内の全員がベースフィーに、ガス加重の中央値プレミアムを加えた額を支払い、新しいトランザクションフィールドなしで手数料の急騰をならすことを狙う。","ko":"EIP-1559의 정체된 대안. 블록의 모든 사람이 베이스 피에 가스 가중 중앙값 프리미엄을 더한 금액을 내며, 새로운 트랜잭션 필드 없이 수수료 급등을 완화하는 것을 목표로 한다.","zh":"一项已停滞的 EIP-1559 替代方案：区块内所有人都支付基础费用加上按 gas 加权的中位数溢价，目标是在不新增交易字段的情况下平滑费用飙升。"},"tags":["gas","fees","core","fee-market","stagnant"],"explainers":{"en":{"lang":"en","tldr":"A stagnant alternative to EIP-1559 in which everyone in a block pays the base fee plus a gas-weighted median premium, aiming to smooth fee spikes without new transaction fields.","tags":["gas","fees","core","fee-market","stagnant"],"related":[1559,3198,3332],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3416/","markdown":"## What problem does it solve?\n\nBefore 2021, Ethereum used a first-price auction: each transaction paid exactly the `gasPrice` it bid. Users had to guess what others would bid, fees jumped minute to minute, and many overpaid.\n\n[EIP-1559](/eip-1559/) was the leading fix. The authors of EIP-3416 argued that 1559 does not really smooth the **tip** (priority fee) part of the price, and they proposed a different design. It keeps a protocol base fee, but replaces individual tips with a single block-wide premium derived from a median, so the final price is harder to manipulate and usually below what the user offered.\n\n## How it works\n\n- **Base fee**: set by the protocol each block from the parent's gas usage, but with an **additive** update rule instead of 1559's multiplicative one:\n  `BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE` with `BASE_FEE_MAX_CHANGE = 1/8`. The authors chose this to resist an attack, observed in simulation, that drives a multiplicative base fee towards zero.\n- **No new transaction format**: legacy transactions are reused, and their `gasPrice` is reinterpreted as a **fee cap**. A transaction with `fee cap \u003c base fee` cannot be included yet.\n- **Implied premium**: each transaction's premium is `(fee cap - base fee) / 2`, half of its headroom.\n- **Uniform block price**: everyone in the block pays `BASE_FEE + weighted_median(premiums)`. The median is weighted by gas used, and the top 5 % of gas by price is excluded as outliers to limit block-producer manipulation.\n- Users are charged that price times gas used, with the usual refund of unused gas. Block producers can still fill blocks greedily by fee cap, because the premium rises with the fee cap.\n\n## Sample code\n\nPseudocode for the per-block price (simplified from the spec):\n\n```python\ndef block_gas_price(base_fee, txs):\n    # each tx: (fee_cap, gas_used)\n    units = sorted(\n        ((base_fee + (cap - base_fee) // 2, gas) for cap, gas in txs if cap \u003e= base_fee),\n        key=lambda x: x[0],\n    )\n    total = sum(g for _, g in units)\n    cutoff = total * 95 // 100        # ignore the most expensive 5 % of gas\n    half, seen = cutoff // 2, 0\n    for price, gas in units:\n        seen += gas\n        if seen \u003e= half:\n            return price              # gas-weighted median, outliers excluded\n    return base_fee\n\ndef charge(tx, price, gas_used):\n    return price * gas_used           # same price for every tx in the block\n```\n\n## Things to know\n\n- Status: **Stagnant**. It was never scheduled. Ethereum adopted [EIP-1559](/eip-1559/) in the London upgrade instead, with explicit `maxFeePerGas` / `maxPriorityFeePerGas` fields and a burned base fee.\n- Several parameters were left undefined (`FORK_BLOCK_NUMBER`, how the per-block gas target is derived), and Test Cases are \"TBD\".\n- Because everyone in a block pays the same price, a user cannot reliably pay extra for priority within a block. The spec argues block producers will still prefer higher fee caps because they raise the median.\n- If you need on-chain access to the actual fee level today, use `BASEFEE` from [EIP-3198](/eip-3198/).\n"},"ja":{"lang":"ja","tldr":"EIP-1559 に代わる停滞中の案。ブロック内の全員がベースフィーに、ガス加重の中央値プレミアムを加えた額を支払い、新しいトランザクションフィールドなしで手数料の急騰をならすことを狙う。","tags":["gas","fees","core","fee-market","stagnant"],"related":[1559,3198,3332],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3416/","markdown":"## 何を解決するのか\n\n2021 年以前、Ethereum は第一価格オークションを採用していました。各トランザクションは、入札した `gasPrice` をそのまま支払います。ユーザーは他の人が何を入札するかを推測する必要があり、手数料は分単位で跳ね上がり、多くの人が払いすぎていました。\n\n[EIP-1559](/eip-1559/) が有力な解決策でした。EIP-3416 の著者たちは、1559 は価格のうち**チップ**（プライオリティフィー）の部分を実際にはならしていないと主張し、別の設計を提案しました。これはプロトコルのベースフィーを保ちつつ、個々のチップを、中央値から導かれるブロック全体で共通の 1 つのプレミアムに置き換えます。そのため、最終的な価格は操作しにくく、通常はユーザーが提示した額を下回ります。\n\n## 仕組み\n\n- **ベースフィー**: 親ブロックのガス使用量から、ブロックごとにプロトコルが設定します。ただし更新ルールは 1559 の乗算的なものではなく、**加算的**です。\n  `BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE`、`BASE_FEE_MAX_CHANGE = 1/8`。著者がこれを選んだのは、シミュレーションで観察された、乗算的なベースフィーをゼロに向かわせる攻撃に耐えるためです。\n- **新しいトランザクション形式はなし**: レガシートランザクションを再利用し、その `gasPrice` を**手数料上限**として解釈し直します。`手数料上限 \u003c ベースフィー` のトランザクションは、まだ取り込めません。\n- **暗黙のプレミアム**: 各トランザクションのプレミアムは `(手数料上限 - ベースフィー) / 2`、つまり余裕分の半分です。\n- **ブロック共通の価格**: ブロック内の全員が `BASE_FEE + weighted_median(premiums)` を支払います。中央値は使用ガスで加重され、価格が上位 5 % のガスは外れ値として除外され、ブロックプロデューサーによる操作を抑えます。\n- ユーザーには、その価格に使用ガスを掛けた額が課金され、未使用ガスは通常どおり返金されます。プレミアムは手数料上限とともに上がるため、ブロックプロデューサーは引き続き、手数料上限の順に貪欲にブロックを埋められます。\n\n## サンプルコード\n\nブロックごとの価格の擬似コード（仕様を簡略化したもの）:\n\n```python\ndef block_gas_price(base_fee, txs):\n    # each tx: (fee_cap, gas_used)\n    units = sorted(\n        ((base_fee + (cap - base_fee) // 2, gas) for cap, gas in txs if cap \u003e= base_fee),\n        key=lambda x: x[0],\n    )\n    total = sum(g for _, g in units)\n    cutoff = total * 95 // 100        # ignore the most expensive 5 % of gas\n    half, seen = cutoff // 2, 0\n    for price, gas in units:\n        seen += gas\n        if seen \u003e= half:\n            return price              # gas-weighted median, outliers excluded\n    return base_fee\n\ndef charge(tx, price, gas_used):\n    return price * gas_used           # same price for every tx in the block\n```\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。予定されたことはありません。Ethereum は代わりに、London アップグレードで [EIP-1559](/eip-1559/) を採用しました。明示的な `maxFeePerGas` / `maxPriorityFeePerGas` フィールドと、バーンされるベースフィーを備えています。\n- いくつかのパラメーターは未定義のままでした（`FORK_BLOCK_NUMBER`、ブロックごとのガスターゲットの導出方法）。Test Cases は「TBD」です。\n- ブロック内の全員が同じ価格を支払うため、ユーザーはブロック内での優先のために確実に上乗せを払うことはできません。仕様は、手数料上限が高いほど中央値が上がるため、ブロックプロデューサーは引き続き高い手数料上限を好むと主張しています。\n- 現在、実際の手数料水準にオンチェーンでアクセスする必要がある場合は、[EIP-3198](/eip-3198/) の `BASEFEE` を使ってください。\n"},"ko":{"lang":"ko","tldr":"EIP-1559의 정체된 대안. 블록의 모든 사람이 베이스 피에 가스 가중 중앙값 프리미엄을 더한 금액을 내며, 새로운 트랜잭션 필드 없이 수수료 급등을 완화하는 것을 목표로 한다.","tags":["gas","fees","core","fee-market","stagnant"],"related":[1559,3198,3332],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3416/","markdown":"## 어떤 문제를 해결하나요?\n\n2021년 이전 이더리움은 최고가 경매 방식이었습니다. 각 트랜잭션은 입찰한 `gasPrice`를 그대로 냈습니다. 사용자는 다른 사람들이 얼마를 입찰할지 추측해야 했고, 수수료는 분 단위로 널뛰었으며, 많은 사람이 과하게 냈습니다.\n\n[EIP-1559](/eip-1559/)가 유력한 해결책이었습니다. EIP-3416의 저자들은 1559가 가격 중 **팁**(우선 수수료) 부분을 실제로는 완화하지 못한다고 주장하며 다른 설계를 제안했습니다. 프로토콜 베이스 피는 유지하되 개별 팁을 중앙값에서 도출한 블록 전체 단일 프리미엄으로 대체하므로, 최종 가격은 조작하기 어렵고 보통 사용자가 제시한 금액보다 낮습니다.\n\n## 어떻게 동작하나요?\n\n- **베이스 피**: 부모 블록의 가스 사용량으로 블록마다 프로토콜이 정하되, 갱신 규칙은 1559의 곱셈식이 아닌 **덧셈식**입니다.\n  `BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE`, `BASE_FEE_MAX_CHANGE = 1/8`. 저자들은 시뮬레이션에서 관찰된, 곱셈식 베이스 피를 0으로 몰아가는 공격에 맞서기 위해 이를 선택했습니다.\n- **새 트랜잭션 형식 없음**: 레거시 트랜잭션을 재사용하며, 그 `gasPrice`를 **수수료 상한**으로 다시 해석합니다. `수수료 상한 \u003c 베이스 피`인 트랜잭션은 아직 포함될 수 없습니다.\n- **암묵적 프리미엄**: 각 트랜잭션의 프리미엄은 `(수수료 상한 - 베이스 피) / 2`, 즉 여유분의 절반입니다.\n- **블록 단일 가격**: 블록의 모든 사람이 `BASE_FEE + weighted_median(premiums)`를 냅니다. 중앙값은 사용 가스로 가중되고, 가격 기준 상위 5%의 가스는 이상치로 제외해 블록 생산자의 조작을 제한합니다.\n- 사용자에게는 그 가격에 사용한 가스를 곱한 금액이 청구되며, 사용하지 않은 가스는 평소처럼 환불됩니다. 프리미엄이 수수료 상한과 함께 오르므로, 블록 생산자는 여전히 수수료 상한 순으로 탐욕적으로 블록을 채울 수 있습니다.\n\n## 샘플 코드\n\n블록별 가격의 의사 코드(명세를 단순화한 것):\n\n```python\ndef block_gas_price(base_fee, txs):\n    # each tx: (fee_cap, gas_used)\n    units = sorted(\n        ((base_fee + (cap - base_fee) // 2, gas) for cap, gas in txs if cap \u003e= base_fee),\n        key=lambda x: x[0],\n    )\n    total = sum(g for _, g in units)\n    cutoff = total * 95 // 100        # ignore the most expensive 5 % of gas\n    half, seen = cutoff // 2, 0\n    for price, gas in units:\n        seen += gas\n        if seen \u003e= half:\n            return price              # gas-weighted median, outliers excluded\n    return base_fee\n\ndef charge(tx, price, gas_used):\n    return price * gas_used           # same price for every tx in the block\n```\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 예정된 적이 없습니다. 이더리움은 대신 런던 업그레이드에서 [EIP-1559](/eip-1559/)를 채택했으며, 명시적인 `maxFeePerGas` / `maxPriorityFeePerGas` 필드와 소각되는 베이스 피를 갖습니다.\n- 여러 매개변수가 정의되지 않은 채로 남았고(`FORK_BLOCK_NUMBER`, 블록별 가스 목표를 도출하는 방법), Test Cases는 \"TBD\"입니다.\n- 블록의 모든 사람이 같은 가격을 내므로 사용자는 블록 안에서 우선순위를 위해 웃돈을 확실히 낼 수 없습니다. 명세는 수수료 상한이 높을수록 중앙값이 올라가므로 블록 생산자가 여전히 높은 수수료 상한을 선호할 것이라고 주장합니다.\n- 오늘날 실제 수수료 수준에 온체인으로 접근해야 한다면 [EIP-3198](/eip-3198/)의 `BASEFEE`를 사용하세요.\n"},"zh":{"lang":"zh","tldr":"一项已停滞的 EIP-1559 替代方案：区块内所有人都支付基础费用加上按 gas 加权的中位数溢价，目标是在不新增交易字段的情况下平滑费用飙升。","tags":["gas","fees","core","fee-market","stagnant"],"related":[1559,3198,3332],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3416/","markdown":"## 它解决什么问题？\n\n2021 年之前，以太坊采用第一价格拍卖：每笔交易恰好支付它所出价的 `gasPrice`。用户必须猜测别人会出什么价，费用每分钟都在跳动，许多人付多了。\n\n[EIP-1559](/eip-1559/) 是当时领先的解决方案。EIP-3416 的作者认为 1559 并没有真正平滑价格中的**小费**（优先费）部分，于是提出了另一种设计。它保留协议的基础费用，但用由中位数得出的、全区块统一的单一溢价取代各笔交易各自的小费，因此最终价格更难被操纵，而且通常低于用户的出价。\n\n## 它如何运作\n\n- **基础费用**：由协议每个区块根据父区块的 gas 使用量设定，但采用的是**加法**更新规则，而不是 1559 的乘法规则：\n  `BASE_FEE = PARENT_BASE_FEE + GAS_DELTA * BASE_FEE_MAX_CHANGE`，其中 `BASE_FEE_MAX_CHANGE = 1/8`。作者选择这样做，是为了抵御模拟中观察到的一种会把乘法式基础费用推向零的攻击。\n- **没有新的交易格式**：沿用传统交易，其 `gasPrice` 被重新解释为**费用上限**。`费用上限 \u003c 基础费用` 的交易暂时无法被包含。\n- **隐含溢价**：每笔交易的溢价为 `(费用上限 - 基础费用) / 2`，即其余量的一半。\n- **区块统一价格**：区块内所有人都支付 `BASE_FEE + weighted_median(premiums)`。中位数按使用的 gas 加权，价格最高的 5% gas 被作为异常值排除，以限制区块生产者的操纵。\n- 用户按该价格乘以使用的 gas 被收费，未使用的 gas 照常退还。区块生产者仍然可以按费用上限贪心地填满区块，因为溢价随费用上限上升。\n\n## 示例代码\n\n每个区块价格的伪代码（对规范做了简化）：\n\n```python\ndef block_gas_price(base_fee, txs):\n    # each tx: (fee_cap, gas_used)\n    units = sorted(\n        ((base_fee + (cap - base_fee) // 2, gas) for cap, gas in txs if cap \u003e= base_fee),\n        key=lambda x: x[0],\n    )\n    total = sum(g for _, g in units)\n    cutoff = total * 95 // 100        # ignore the most expensive 5 % of gas\n    half, seen = cutoff // 2, 0\n    for price, gas in units:\n        seen += gas\n        if seen \u003e= half:\n            return price              # gas-weighted median, outliers excluded\n    return base_fee\n\ndef charge(tx, price, gas_used):\n    return price * gas_used           # same price for every tx in the block\n```\n\n## 需要注意\n\n- 状态：**Stagnant**。它从未被排期。以太坊转而在伦敦升级中采用了 [EIP-1559](/eip-1559/)，带有明确的 `maxFeePerGas` / `maxPriorityFeePerGas` 字段和被销毁的基础费用。\n- 若干参数未定义（`FORK_BLOCK_NUMBER`，以及每个区块的 gas 目标如何得出），Test Cases 为\"TBD\"。\n- 由于区块内所有人支付相同的价格，用户无法可靠地通过多付钱在区块内获得优先。规范认为区块生产者仍会偏好更高的费用上限，因为它们会抬高中位数。\n- 如果你现在需要在链上获取实际的费用水平，请使用 [EIP-3198](/eip-3198/) 的 `BASEFEE`。\n"}}}
