{"eip":2046,"title":"Reduced gas cost for static calls made to precompiles","description":"This change reduces the gas cost of using precompiled contracts.","authors":["Alex Beregszaszi (@axic)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2019-05-17","requires":[214,1352],"discussionsTo":"https://ethereum-magicians.org/t/eip-2046-reduced-gas-cost-for-static-calls-made-to-precompiles/3291","repo":"EIPs","label":"EIP-2046","officialUrl":"https://eips.ethereum.org/EIPS/eip-2046","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2046.md","url":"https://eips.huatuo.xyz/eip-2046/","tldr":{"en":"Proposed cutting the base cost of a STATICCALL to a precompile from 700 to 40 gas, making cheap cryptographic precompiles practical to call.","ja":"プリコンパイルへの STATICCALL の基本コストを 700 gas から 40 gas に引き下げることを提案し、安価な暗号プリコンパイルを実用的に呼び出せるようにした。","ko":"프리컴파일에 대한 STATICCALL의 기본 비용을 700 gas에서 40 gas로 낮추자고 제안해, 저렴한 암호화 프리컴파일을 현실적으로 호출할 수 있게 하려 했다.","zh":"提议把对预编译合约的 STATICCALL 基础成本从 700 gas 降到 40 gas，使调用廉价的密码学预编译合约变得切实可行。"},"tags":["evm","gas","precompiles","staticcall","stagnant"],"explainers":{"en":{"lang":"en","tldr":"Proposed cutting the base cost of a STATICCALL to a precompile from 700 to 40 gas, making cheap cryptographic precompiles practical to call.","tags":["evm","gas","precompiles","staticcall","stagnant"],"related":[214,1352,1109,2929],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-2046/","markdown":"## What problem does it solve?\n\n**Precompiles** are built-in contracts at fixed low addresses (e.g. `ecrecover`, SHA-256, elliptic-curve operations) that clients implement natively. Calling one still goes through the normal `CALL`-family opcodes and pays their base cost.\n\nThe Spurious Dragon fork raised that base cost to 700 gas to reflect loading another contract's code from disk. Precompiles have no code to load, yet paid the same price. For a precompile whose own work costs much less than 700 gas, the call overhead dominated, and some uses became impractical.\n\n## How it works\n\nAfter the activating fork, the base cost of `STATICCALL` (`0xfa`, from [EIP-214](/eip-214/)) depends on the target:\n\n| Target | Base cost |\n| --- | --- |\n| Precompile (address range defined by [EIP-1352](/eip-1352/)) | 40 |\n| Any other address | 700 (unchanged) |\n\nDesign choices from the spec:\n\n- **Only `STATICCALL`** is changed, to limit impact. Precompiles are stateless, so calling them statically loses nothing. Contracts deployed before Byzantium, which predate `STATICCALL`, would not benefit.\n- **Not zero.** 40 gas is kept to represent the context switch. This also keeps the call from being free, so older proxy contracts cannot use it to sneak in state changes.\n- An earlier, similar idea appeared in [EIP-1109](/eip-1109/), which later took a different approach.\n\n## Sample code\n\nCalling the SHA-256 precompile (address `0x02`) with `staticcall`, the kind of call this EIP would make cheaper:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Hasher {\n    function sha(bytes memory data) external view returns (bytes32 out) {\n        (bool ok, bytes memory ret) = address(0x02).staticcall(data);\n        require(ok, \"precompile failed\");\n        out = abi.decode(ret, (bytes32));\n    }\n}\n```\n\nPseudocode of the pricing rule:\n\n```python\ndef staticcall_base_cost(target):\n    if is_precompile(target):   # per EIP-1352 range\n        return 40\n    return 700\n```\n\n## Things to know\n\n- **Status: Stagnant.** It was never activated. The spec still has a \"FIXME\" in its motivation, and test cases and implementation are \"TBA\".\n- Call pricing changed afterwards anyway: [EIP-2929](/eip-2929/) (Berlin) replaced the flat 700 with warm/cold access costs, and precompile addresses are always treated as warm, so a call to one costs 100 gas base. That addressed much of this EIP's motivation.\n- Some later EIPs repriced individual precompiles directly instead of the call overhead.\n"},"ja":{"lang":"ja","tldr":"プリコンパイルへの STATICCALL の基本コストを 700 gas から 40 gas に引き下げることを提案し、安価な暗号プリコンパイルを実用的に呼び出せるようにした。","tags":["evm","gas","precompiles","staticcall","stagnant"],"related":[214,1352,1109,2929],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-2046/","markdown":"## 何を解決するのか\n\n**プリコンパイル**は、固定された小さなアドレスにある組み込みコントラクト（`ecrecover`、SHA-256、楕円曲線演算など）で、クライアントがネイティブに実装します。呼び出しは通常の `CALL` 系 opcode を経由するため、その基本コストを支払います。\n\nSpurious Dragon フォークは、他のコントラクトのコードをディスクから読み込むコストを反映して、この基本コストを 700 gas に引き上げました。プリコンパイルには読み込むコードがないのに、同じ価格を支払っていました。自身の処理コストが 700 gas よりはるかに小さいプリコンパイルでは、呼び出しのオーバーヘッドが支配的になり、用途によっては実用的でなくなりました。\n\n## 仕組み\n\n有効化されるフォークの後、`STATICCALL`（`0xfa`、[EIP-214](/eip-214/) 由来）の基本コストは呼び出し先によって決まります。\n\n| 呼び出し先 | 基本コスト |\n| --- | --- |\n| プリコンパイル（アドレス範囲は [EIP-1352](/eip-1352/) で定義） | 40 |\n| それ以外のアドレス | 700（変更なし） |\n\n仕様の設計上の選択:\n\n- 影響を抑えるため、変更されるのは **`STATICCALL` のみ**です。プリコンパイルはステートレスなので、静的に呼び出しても失うものはありません。`STATICCALL` が存在しなかった Byzantium 以前にデプロイされたコントラクトは恩恵を受けません。\n- **ゼロにはしない。** コンテキストスイッチを表すために 40 gas を残しています。これにより呼び出しが無料にならず、古いプロキシコントラクトがこれを悪用して状態変更をこっそり行うこともできません。\n- 似た案は以前に [EIP-1109](/eip-1109/) でも出ていましたが、そちらは後に別のアプローチを取りました。\n\n## サンプルコード\n\n`staticcall` で SHA-256 プリコンパイル（アドレス `0x02`）を呼び出す例。この EIP が安くしようとした種類の呼び出しです。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Hasher {\n    function sha(bytes memory data) external view returns (bytes32 out) {\n        (bool ok, bytes memory ret) = address(0x02).staticcall(data);\n        require(ok, \"precompile failed\");\n        out = abi.decode(ret, (bytes32));\n    }\n}\n```\n\n価格ルールの擬似コード:\n\n```python\ndef staticcall_base_cost(target):\n    if is_precompile(target):   # per EIP-1352 range\n        return 40\n    return 700\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** 有効化されることはありませんでした。仕様の motivation にはまだ「FIXME」が残っており、テストケースと実装は「TBA」のままです。\n- その後、呼び出し価格は別の形で変わりました。[EIP-2929](/eip-2929/)（Berlin）は一律 700 を warm/cold アクセスコストに置き換え、プリコンパイルのアドレスは常に warm として扱われるため、プリコンパイルへの呼び出しの基本コストは 100 gas になりました。これでこの EIP の動機の多くは解消されました。\n- 後続の EIP の中には、呼び出しのオーバーヘッドではなく個々のプリコンパイルの価格を直接見直したものもあります。\n"},"ko":{"lang":"ko","tldr":"프리컴파일에 대한 STATICCALL의 기본 비용을 700 gas에서 40 gas로 낮추자고 제안해, 저렴한 암호화 프리컴파일을 현실적으로 호출할 수 있게 하려 했다.","tags":["evm","gas","precompiles","staticcall","stagnant"],"related":[214,1352,1109,2929],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-2046/","markdown":"## 어떤 문제를 해결하나요?\n\n**프리컴파일**은 고정된 낮은 주소에 있는 내장 컨트랙트(`ecrecover`, SHA-256, 타원곡선 연산 등)로, 클라이언트가 네이티브로 구현합니다. 호출은 여전히 일반 `CALL` 계열 opcode를 거치므로 그 기본 비용을 냅니다.\n\nSpurious Dragon 포크는 다른 컨트랙트의 코드를 디스크에서 불러오는 비용을 반영해 이 기본 비용을 700 gas로 올렸습니다. 프리컴파일은 불러올 코드가 없는데도 같은 가격을 냈습니다. 자체 작업 비용이 700 gas보다 훨씬 작은 프리컴파일에서는 호출 오버헤드가 지배적이었고, 일부 용도는 비현실적이 되었습니다.\n\n## 어떻게 동작하나요?\n\n활성화 포크 이후 `STATICCALL`(`0xfa`, [EIP-214](/eip-214/) 유래)의 기본 비용은 대상에 따라 달라집니다.\n\n| 대상 | 기본 비용 |\n| --- | --- |\n| 프리컴파일([EIP-1352](/eip-1352/)가 정의한 주소 범위) | 40 |\n| 그 외 모든 주소 | 700(변경 없음) |\n\n스펙의 설계 선택:\n\n- 영향을 제한하기 위해 **`STATICCALL`만** 바뀝니다. 프리컴파일은 상태가 없으므로 정적으로 호출해도 잃는 것이 없습니다. `STATICCALL`보다 앞선 Byzantium 이전에 배포된 컨트랙트는 혜택을 받지 못합니다.\n- **0은 아닙니다.** 컨텍스트 전환을 나타내기 위해 40 gas를 유지합니다. 호출이 공짜가 되지 않으므로, 오래된 프록시 컨트랙트가 이를 이용해 상태 변경을 몰래 끼워 넣을 수도 없습니다.\n- 비슷한 아이디어가 앞서 [EIP-1109](/eip-1109/)에 나왔는데, 이는 나중에 다른 접근을 택했습니다.\n\n## 샘플 코드\n\n`staticcall`로 SHA-256 프리컴파일(주소 `0x02`)을 호출하는 예로, 이 EIP가 더 싸게 만들려던 종류의 호출입니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Hasher {\n    function sha(bytes memory data) external view returns (bytes32 out) {\n        (bool ok, bytes memory ret) = address(0x02).staticcall(data);\n        require(ok, \"precompile failed\");\n        out = abi.decode(ret, (bytes32));\n    }\n}\n```\n\n가격 규칙의 의사 코드:\n\n```python\ndef staticcall_base_cost(target):\n    if is_precompile(target):   # per EIP-1352 range\n        return 40\n    return 700\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 활성화된 적이 없습니다. 스펙의 motivation에는 아직 \"FIXME\"가 남아 있고, 테스트 케이스와 구현은 \"TBA\"입니다.\n- 이후 호출 가격은 어차피 바뀌었습니다. [EIP-2929](/eip-2929/)(Berlin)가 고정 700을 warm/cold 접근 비용으로 대체했고, 프리컴파일 주소는 항상 warm으로 취급되므로 프리컴파일 호출의 기본 비용은 100 gas가 되었습니다. 이로써 이 EIP의 동기 상당 부분이 해결되었습니다.\n- 이후 일부 EIP는 호출 오버헤드 대신 개별 프리컴파일의 가격을 직접 조정했습니다.\n"},"zh":{"lang":"zh","tldr":"提议把对预编译合约的 STATICCALL 基础成本从 700 gas 降到 40 gas，使调用廉价的密码学预编译合约变得切实可行。","tags":["evm","gas","precompiles","staticcall","stagnant"],"related":[214,1352,1109,2929],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-2046/","markdown":"## 它解决什么问题？\n\n**预编译合约（precompile）**是位于固定的低地址上的内置合约（如 `ecrecover`、SHA-256、椭圆曲线运算），由客户端原生实现。调用它们仍然要经过普通的 `CALL` 系列 opcode，并支付其基础成本。\n\nSpurious Dragon 分叉把这一基础成本提高到 700 gas，以反映从磁盘加载另一个合约代码的开销。预编译合约没有代码需要加载，却支付了同样的价格。对于自身工作成本远低于 700 gas 的预编译合约，调用开销占了主导，某些用法因此变得不切实际。\n\n## 它如何运作\n\n在该提案激活的分叉之后，`STATICCALL`（`0xfa`，来自 [EIP-214](/eip-214/)）的基础成本取决于目标：\n\n| 目标 | 基础成本 |\n| --- | --- |\n| 预编译合约（地址范围由 [EIP-1352](/eip-1352/) 定义） | 40 |\n| 其他任何地址 | 700（不变） |\n\n规范中的设计取舍：\n\n- **仅修改 `STATICCALL`**，以限制影响范围。预编译合约是无状态的，因此以静态方式调用它们不会损失任何东西。在 Byzantium 之前部署、早于 `STATICCALL` 的合约不会受益。\n- **不降为零。** 保留 40 gas 以体现上下文切换的成本。这也使调用不会免费，因此较旧的代理合约无法借此偷偷进行状态更改。\n- 更早出现过类似的想法 [EIP-1109](/eip-1109/)，后来它采取了另一种思路。\n\n## 示例代码\n\n用 `staticcall` 调用 SHA-256 预编译合约（地址 `0x02`），这正是该 EIP 想让它更便宜的那类调用：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Hasher {\n    function sha(bytes memory data) external view returns (bytes32 out) {\n        (bool ok, bytes memory ret) = address(0x02).staticcall(data);\n        require(ok, \"precompile failed\");\n        out = abi.decode(ret, (bytes32));\n    }\n}\n```\n\n定价规则的伪代码：\n\n```python\ndef staticcall_base_cost(target):\n    if is_precompile(target):   # per EIP-1352 range\n        return 40\n    return 700\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 它从未被激活。规范的动机部分仍留有「FIXME」，测试用例和实现仍是「TBA」。\n- 此后调用定价还是发生了变化：[EIP-2929](/eip-2929/)（Berlin）用 warm/cold 访问成本取代了固定的 700，并且预编译合约地址始终被视为 warm，因此调用它的基础成本为 100 gas。这解决了该 EIP 的大部分动机。\n- 后来的一些 EIP 直接重新定价了个别预编译合约，而不是调整调用开销。\n"}},"requiredBy":[2539,2666]}
