{"eip":7889,"title":"Emit log on revert","description":"Top level reverts emit a log with revert message","authors":["Shoham Chakraborty (@shohamc1)","Alex Forshtat (@forshtat)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2025-02-20","discussionsTo":"https://ethereum-magicians.org/t/eip-7889-emit-log-on-revert/22918","repo":"EIPs","label":"EIP-7889","officialUrl":"https://eips.ethereum.org/EIPS/eip-7889","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7889.md","url":"https://eips.huatuo.xyz/eip-7889/","tldr":{"en":"Proposes that every REVERT with data automatically emits a log carrying the revert message, so wallets and explorers can read failure reasons over standard RPC instead of re-tracing the transaction.","ja":"データ付きの REVERT がすべて、revert メッセージを載せたログを自動的に emit することを提案する。ウォレットやエクスプローラーが、トランザクションを再トレースせずに、標準の RPC で失敗理由を読めるようになる。","ko":"데이터가 있는 모든 REVERT가 revert 메시지를 담은 로그를 자동으로 emit하도록 제안한다. 지갑과 탐색기가 트랜잭션을 다시 트레이싱하지 않고도 표준 RPC로 실패 사유를 읽을 수 있다.","zh":"提议每个带数据的 REVERT 都自动触发一条携带 revert 消息的日志，使钱包和浏览器可以通过标准 RPC 读取失败原因，而无需重新追踪交易。"},"tags":["evm","revert","logs","rpc","core"],"explainers":{"en":{"lang":"en","tldr":"Proposes that every REVERT with data automatically emits a log carrying the revert message, so wallets and explorers can read failure reasons over standard RPC instead of re-tracing the transaction.","tags":["evm","revert","logs","rpc","core"],"related":[140,658],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7889/","markdown":"## What problem does it solve?\n\nWhen a transaction fails, the reason (\"insufficient balance\", a custom error, etc.) is passed to the `REVERT` opcode ([EIP-140](/eip-140/)), but it is not stored anywhere a normal RPC call can read it. The receipt only says the transaction failed ([EIP-658](/eip-658/) status `0`). To find out *why*, a user or tool has to ask a node to trace the transaction, which means replaying it in full to recover a few bytes of data. Many public RPC providers restrict or charge for tracing.\n\nSome smart-wallet developers work around this by emitting their own log right before reverting, but that is ad hoc and cannot be relied on by libraries or block explorers. EIP-7889 proposes making this behaviour part of the protocol.\n\n## How it works\n\n- Whenever `REVERT` is executed with a non-zero data size, the EVM emits a log equivalent to a `LOG1`.\n- The single topic is a fixed constant `REVERTTOPIC`.\n- The log data is the raw revert bytes (the ABI-encoded `Error(string)` or custom error), truncated to `DATA_LIMIT`.\n- Both `REVERTTOPIC` and `DATA_LIMIT` are still marked **TBD** in the spec.\n\nBecause a reverted transaction normally keeps no logs, the visible change is that a reverted transaction's receipt can now contain up to one log. Clients and indexers read it with the existing `eth_getTransactionReceipt` / `eth_getLogs`, so no new RPC method or opcode is needed.\n\nPseudocode for the proposed rule:\n\n```python\ndef op_revert(evm, offset, size):\n    data = evm.memory[offset:offset + size]\n    if size \u003e 0:\n        emit_log(address=evm.address,\n                 topics=[REVERTTOPIC],          # constant, value TBD\n                 data=data[:DATA_LIMIT])        # limit TBD\n    evm.halt_with_revert(data)\n```\n\n## Sample code\n\nA contract that reverts with a custom error. Under this proposal the encoded error would appear as log data in the failed transaction's receipt:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Vault {\n    error InsufficientBalance(uint256 available, uint256 required);\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external {\n        uint256 bal = balance[msg.sender];\n        if (bal \u003c amount) revert InsufficientBalance(bal, amount);\n        balance[msg.sender] = bal - amount;\n        payable(msg.sender).transfer(amount);\n    }\n}\n```\n\nHow a client could then decode it from the receipt (ethers v6), once a topic value is fixed:\n\n```ts\nimport { Interface } from \"ethers\";\n\nconst iface = new Interface([\"error InsufficientBalance(uint256 available, uint256 required)\"]);\nconst receipt = await provider.getTransactionReceipt(txHash);\nconst log = receipt!.logs.find((l) =\u003e l.topics[0] === REVERT_TOPIC); // REVERT_TOPIC not yet defined\nif (log) console.log(iface.parseError(log.data)); // InsufficientBalance(…)\n```\n\n## Things to know\n\n- **Status: Stagnant.** The proposal has not progressed and its key parameters (`REVERTTOPIC`, `DATA_LIMIT`) were never set. Nothing on mainnet emits these logs today; you still need `debug_traceTransaction` or a re-simulation with `eth_call` to recover revert reasons.\n- The authors argue it does not add a storage-bloat vector: a reverted transaction already costs at least 21,000 gas, far more than a `LOG1`. It would, however, increase the average number of logs.\n- Only reverts with data would produce a log; a bare `revert()` with zero size would not.\n- Tools that assume \"failed transaction ⇒ no logs\" would need to be updated if this were ever adopted.\n"},"ja":{"lang":"ja","tldr":"データ付きの REVERT がすべて、revert メッセージを載せたログを自動的に emit することを提案する。ウォレットやエクスプローラーが、トランザクションを再トレースせずに、標準の RPC で失敗理由を読めるようになる。","tags":["evm","revert","logs","rpc","core"],"related":[140,658],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7889/","markdown":"## 何を解決するのか\n\nトランザクションが失敗したとき、その理由（「残高不足」やカスタムエラーなど）は `REVERT` オペコード（[EIP-140](/eip-140/)）に渡されますが、通常の RPC 呼び出しで読める場所には保存されません。レシートが示すのはトランザクションが失敗したこと（[EIP-658](/eip-658/) のステータス `0`）だけです。*なぜ*失敗したかを知るには、ユーザーやツールがノードにトランザクションのトレースを依頼する必要があり、わずか数バイトのデータを取り出すために全体を再実行することになります。多くの公開 RPC プロバイダーは、トレースを制限したり課金したりしています。\n\n一部のスマートウォレットの開発者は、revert の直前に独自のログを emit することでこれを回避していますが、場当たり的で、ライブラリやブロックエクスプローラーが頼りにすることはできません。EIP-7889 は、この挙動をプロトコルの一部にすることを提案します。\n\n## 仕組み\n\n- データサイズが 0 以外で `REVERT` が実行されるたびに、EVM は `LOG1` に相当するログを emit します。\n- 唯一のトピックは、固定の定数 `REVERTTOPIC` です。\n- ログデータは revert の生のバイト列（ABI エンコードされた `Error(string)` またはカスタムエラー）で、`DATA_LIMIT` で切り詰められます。\n- `REVERTTOPIC` と `DATA_LIMIT` は、仕様ではどちらもまだ **TBD** とされています。\n\nrevert されたトランザクションは通常ログを保持しないため、目に見える変化は、revert されたトランザクションのレシートに最大 1 つのログが含まれうることです。クライアントやインデクサーは既存の `eth_getTransactionReceipt` / `eth_getLogs` で読めるため、新しい RPC メソッドもオペコードも不要です。\n\n提案されているルールの擬似コード:\n\n```python\ndef op_revert(evm, offset, size):\n    data = evm.memory[offset:offset + size]\n    if size \u003e 0:\n        emit_log(address=evm.address,\n                 topics=[REVERTTOPIC],          # constant, value TBD\n                 data=data[:DATA_LIMIT])        # limit TBD\n    evm.halt_with_revert(data)\n```\n\n## サンプルコード\n\nカスタムエラーで revert するコントラクト。この提案のもとでは、エンコードされたエラーが、失敗したトランザクションのレシートにログデータとして現れます。\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Vault {\n    error InsufficientBalance(uint256 available, uint256 required);\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external {\n        uint256 bal = balance[msg.sender];\n        if (bal \u003c amount) revert InsufficientBalance(bal, amount);\n        balance[msg.sender] = bal - amount;\n        payable(msg.sender).transfer(amount);\n    }\n}\n```\n\nトピックの値が固まった場合に、クライアントがレシートからこれをデコードする方法（ethers v6）:\n\n```ts\nimport { Interface } from \"ethers\";\n\nconst iface = new Interface([\"error InsufficientBalance(uint256 available, uint256 required)\"]);\nconst receipt = await provider.getTransactionReceipt(txHash);\nconst log = receipt!.logs.find((l) =\u003e l.topics[0] === REVERT_TOPIC); // REVERT_TOPIC not yet defined\nif (log) console.log(iface.parseError(log.data)); // InsufficientBalance(…)\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** 提案は進んでおらず、主要なパラメーター（`REVERTTOPIC`、`DATA_LIMIT`）は一度も決まりませんでした。現在、メインネットでこれらのログを emit するものはありません。revert の理由を取り出すには、引き続き `debug_traceTransaction` か、`eth_call` による再シミュレーションが必要です。\n- 著者は、ストレージ肥大化の経路を増やさないと主張しています。revert されたトランザクションはすでに少なくとも 21,000 ガスかかり、`LOG1` よりはるかに高いためです。ただし、ログの平均数は増えます。\n- ログが生成されるのは、データ付きの revert だけです。サイズ 0 の素の `revert()` では生成されません。\n- 「失敗したトランザクションならログなし」を前提とするツールは、これが採用された場合には更新が必要になります。\n"},"ko":{"lang":"ko","tldr":"데이터가 있는 모든 REVERT가 revert 메시지를 담은 로그를 자동으로 emit하도록 제안한다. 지갑과 탐색기가 트랜잭션을 다시 트레이싱하지 않고도 표준 RPC로 실패 사유를 읽을 수 있다.","tags":["evm","revert","logs","rpc","core"],"related":[140,658],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7889/","markdown":"## 어떤 문제를 해결하나요?\n\n트랜잭션이 실패하면 그 사유(\"잔액 부족\", 커스텀 에러 등)는 `REVERT` 오퍼코드([EIP-140](/eip-140/))에 전달되지만, 일반 RPC 호출로 읽을 수 있는 곳에는 저장되지 않습니다. 영수증은 트랜잭션이 실패했다는 사실([EIP-658](/eip-658/) 상태 `0`)만 알려줍니다. *왜* 실패했는지 알려면 사용자나 도구가 노드에 트랜잭션 트레이스를 요청해야 하는데, 이는 몇 바이트의 데이터를 얻으려고 전체를 다시 실행하는 것입니다. 많은 공개 RPC 제공자는 트레이싱을 제한하거나 요금을 부과합니다.\n\n일부 스마트 월렛 개발자는 revert 직전에 자체 로그를 emit하는 식으로 이를 우회하지만, 임시방편이라 라이브러리나 블록 탐색기가 의존할 수 없습니다. EIP-7889는 이 동작을 프로토콜의 일부로 만들 것을 제안합니다.\n\n## 어떻게 동작하나요?\n\n- `REVERT`가 0이 아닌 데이터 크기로 실행될 때마다 EVM은 `LOG1`에 해당하는 로그를 emit합니다.\n- 유일한 토픽은 고정 상수 `REVERTTOPIC`입니다.\n- 로그 데이터는 원시 revert 바이트(ABI 인코딩된 `Error(string)` 또는 커스텀 에러)이며 `DATA_LIMIT`까지 잘립니다.\n- `REVERTTOPIC`과 `DATA_LIMIT`은 사양에서 모두 아직 **TBD**로 표시되어 있습니다.\n\nrevert된 트랜잭션은 보통 로그를 남기지 않으므로, 눈에 보이는 변화는 revert된 트랜잭션의 영수증에 이제 최대 하나의 로그가 들어갈 수 있다는 것입니다. 클라이언트와 인덱서는 기존 `eth_getTransactionReceipt` / `eth_getLogs`로 읽으므로 새로운 RPC 메서드나 오퍼코드는 필요하지 않습니다.\n\n제안된 규칙의 의사 코드:\n\n```python\ndef op_revert(evm, offset, size):\n    data = evm.memory[offset:offset + size]\n    if size \u003e 0:\n        emit_log(address=evm.address,\n                 topics=[REVERTTOPIC],          # constant, value TBD\n                 data=data[:DATA_LIMIT])        # limit TBD\n    evm.halt_with_revert(data)\n```\n\n## 샘플 코드\n\n커스텀 에러로 revert하는 컨트랙트. 이 제안에서는 인코딩된 에러가 실패한 트랜잭션의 영수증에 로그 데이터로 나타납니다.\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Vault {\n    error InsufficientBalance(uint256 available, uint256 required);\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external {\n        uint256 bal = balance[msg.sender];\n        if (bal \u003c amount) revert InsufficientBalance(bal, amount);\n        balance[msg.sender] = bal - amount;\n        payable(msg.sender).transfer(amount);\n    }\n}\n```\n\n토픽 값이 확정된 뒤 클라이언트가 영수증에서 이를 디코딩하는 방법(ethers v6):\n\n```ts\nimport { Interface } from \"ethers\";\n\nconst iface = new Interface([\"error InsufficientBalance(uint256 available, uint256 required)\"]);\nconst receipt = await provider.getTransactionReceipt(txHash);\nconst log = receipt!.logs.find((l) =\u003e l.topics[0] === REVERT_TOPIC); // REVERT_TOPIC not yet defined\nif (log) console.log(iface.parseError(log.data)); // InsufficientBalance(…)\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** 제안은 진전이 없고 핵심 파라미터(`REVERTTOPIC`, `DATA_LIMIT`)는 한 번도 정해지지 않았습니다. 현재 메인넷에서 이런 로그를 emit하는 것은 없으며, revert 사유를 얻으려면 여전히 `debug_traceTransaction`이나 `eth_call`을 이용한 재시뮬레이션이 필요합니다.\n- 작성자는 스토리지 팽창 경로를 늘리지 않는다고 주장합니다. revert된 트랜잭션은 이미 최소 21,000 가스가 들며, 이는 `LOG1`보다 훨씬 큽니다. 다만 로그의 평균 개수는 늘어납니다.\n- 로그가 생기는 것은 데이터가 있는 revert뿐이며, 크기가 0인 단순 `revert()`는 생기지 않습니다.\n- \"트랜잭션 실패 ⇒ 로그 없음\"을 가정하는 도구는 이것이 채택되면 업데이트해야 합니다.\n"},"zh":{"lang":"zh","tldr":"提议每个带数据的 REVERT 都自动触发一条携带 revert 消息的日志，使钱包和浏览器可以通过标准 RPC 读取失败原因，而无需重新追踪交易。","tags":["evm","revert","logs","rpc","core"],"related":[140,658],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7889/","markdown":"## 它解决什么问题？\n\n当交易失败时，原因（\"余额不足\"、自定义错误等）会传给 `REVERT` 操作码（[EIP-140](/eip-140/)），但它并不存储在普通 RPC 调用能够读取的地方。收据只说明交易失败了（[EIP-658](/eip-658/) 状态 `0`）。要查明*为什么*失败，用户或工具必须请求节点追踪这笔交易，也就是为了取回几个字节的数据而完整重放一遍。许多公共 RPC 提供商会限制追踪或对其收费。\n\n一些智能钱包开发者的变通办法是在 revert 之前自行触发一条日志，但这是临时做法，库或区块浏览器无法依赖。EIP-7889 提议把这一行为纳入协议。\n\n## 它如何运作\n\n- 每当 `REVERT` 以非零数据大小执行时，EVM 会触发一条等同于 `LOG1` 的日志。\n- 唯一的 topic 是固定常量 `REVERTTOPIC`。\n- 日志数据是原始的 revert 字节（经 ABI 编码的 `Error(string)` 或自定义错误），按 `DATA_LIMIT` 截断。\n- `REVERTTOPIC` 和 `DATA_LIMIT` 在规范中仍标记为 **TBD**。\n\n由于被回滚的交易通常不保留日志，可见的变化是：被 revert 的交易的收据现在最多可以包含一条日志。客户端和索引器用现有的 `eth_getTransactionReceipt` / `eth_getLogs` 读取它，因此不需要新的 RPC 方法或操作码。\n\n所提议规则的伪代码：\n\n```python\ndef op_revert(evm, offset, size):\n    data = evm.memory[offset:offset + size]\n    if size \u003e 0:\n        emit_log(address=evm.address,\n                 topics=[REVERTTOPIC],          # constant, value TBD\n                 data=data[:DATA_LIMIT])        # limit TBD\n    evm.halt_with_revert(data)\n```\n\n## 示例代码\n\n一个以自定义错误 revert 的合约。根据本提案，编码后的错误会作为日志数据出现在失败交易的收据中：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\n\ncontract Vault {\n    error InsufficientBalance(uint256 available, uint256 required);\n    mapping(address =\u003e uint256) public balance;\n\n    function withdraw(uint256 amount) external {\n        uint256 bal = balance[msg.sender];\n        if (bal \u003c amount) revert InsufficientBalance(bal, amount);\n        balance[msg.sender] = bal - amount;\n        payable(msg.sender).transfer(amount);\n    }\n}\n```\n\n一旦 topic 的值确定，客户端就可以这样从收据中解码它（ethers v6）：\n\n```ts\nimport { Interface } from \"ethers\";\n\nconst iface = new Interface([\"error InsufficientBalance(uint256 available, uint256 required)\"]);\nconst receipt = await provider.getTransactionReceipt(txHash);\nconst log = receipt!.logs.find((l) =\u003e l.topics[0] === REVERT_TOPIC); // REVERT_TOPIC not yet defined\nif (log) console.log(iface.parseError(log.data)); // InsufficientBalance(…)\n```\n\n## 需要注意\n\n- **状态：Stagnant。**该提案没有进展，其关键参数（`REVERTTOPIC`、`DATA_LIMIT`）从未确定。目前主网上没有任何东西会触发这些日志；要取回 revert 原因，仍然需要 `debug_traceTransaction`，或用 `eth_call` 重新模拟。\n- 作者认为它不会增加存储膨胀的途径：被 revert 的交易本来就至少花费 21,000 gas，远高于一条 `LOG1`。不过，它会增加日志的平均数量。\n- 只有带数据的 revert 才会产生日志；大小为零的裸 `revert()` 不会。\n- 假设\"交易失败 ⇒ 没有日志\"的工具，如果该提案被采纳，就需要更新。\n"}}}
