{"eip":658,"title":"Embedding transaction status code in receipts","description":"This EIP replaces the intermediate state root field of the receipt with a status code indicating if the top-level call succeeded or failed.","authors":["Nick Johnson \u003cnick@ethereum.org\u003e"],"status":"Final","type":"Standards Track","category":"Core","created":"2017-06-30","requires":[140],"repo":"EIPs","label":"EIP-658","officialUrl":"https://eips.ethereum.org/EIPS/eip-658","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-658.md","url":"https://eips.huatuo.xyz/eip-658/","tldr":{"en":"Replaced the intermediate state root in transaction receipts with a status code (1 = success, 0 = failure), giving every client a reliable way to tell whether a transaction succeeded.","ja":"トランザクションレシート内の中間ステートルートをステータスコード（1 = 成功、0 = 失敗）に置き換え、すべてのクライアントがトランザクションの成否を確実に判定できるようにした。","ko":"트랜잭션 영수증의 중간 상태 루트를 상태 코드(1 = 성공, 0 = 실패)로 대체해, 모든 클라이언트가 트랜잭션의 성공 여부를 안정적으로 알 수 있게 했다.","zh":"用状态码（1 = 成功，0 = 失败）取代交易收据中的中间状态根，使每个客户端都能可靠地判断一笔交易是否成功。"},"tags":["receipts","transactions","core","byzantium"],"explainers":{"en":{"lang":"en","tldr":"Replaced the intermediate state root in transaction receipts with a status code (1 = success, 0 = failure), giving every client a reliable way to tell whether a transaction succeeded.","tags":["receipts","transactions","core","byzantium"],"related":[140,609,2718,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-658/","markdown":"## What problem does it solve?\n\nBefore Byzantium, a common heuristic was \"if a transaction used all its gas, it failed\". [EIP-140](/eip-140/) added the `REVERT` opcode, which undoes state changes **and refunds the remaining gas**. After that, a failed transaction could look like a cheap, successful one.\n\nFull nodes could replay a transaction to find out what happened. Fast-synced nodes could do that only for recent blocks, and light clients could not do it at all. Wallets and dapps needed the result recorded in consensus data.\n\n## How it works\n\nEach receipt used to contain an **intermediate state root**: the state trie root right after that transaction. That field had already been made obsolete by an earlier proposal, EIP-98.\n\nFrom the Byzantium fork on, that field holds a **status code** instead:\n\n- `1` means the top-level call succeeded and its state changes were applied.\n- `0` means it failed for any reason that reverts the transaction, such as `REVERT`, out-of-gas or an invalid opcode.\n\nThe receipt still contains cumulative gas used, the logs bloom and the logs, so the change is a single field. Because receipts are committed in the block header's receipts root, light clients can verify the status with a Merkle proof.\n\n## Sample code\n\nReceipt as RLP, before and after:\n\n```\npre-Byzantium:  [post_state_root (32 bytes), cumulative_gas_used, logs_bloom, logs]\npost-Byzantium: [status (0x01 or empty for 0), cumulative_gas_used, logs_bloom, logs]\n```\n\nChecking the status (ethers v6):\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst receipt = await provider.getTransactionReceipt(txHash);\n\nif (receipt?.status === 1) {\n  console.log(\"success\");\n} else if (receipt?.status === 0) {\n  console.log(\"reverted\");\n}\n```\n\nIn JSON-RPC, `eth_getTransactionReceipt` returns `\"status\": \"0x1\"` or `\"0x0\"`. Pre-Byzantium receipts return a `root` field instead.\n\n## Things to know\n\n- The status describes only the **top-level** call. A transaction can succeed even if an internal call failed and the contract caught the failure.\n- A status of `0` still means the sender paid for the gas used and the nonce was consumed.\n- The status code does not include the revert reason or return data. Read those with `eth_call` or tracing. [EIP-211](/eip-211/) made return data available inside the EVM.\n- Typed transactions ([EIP-2718](/eip-2718/)) keep the status field in their receipts.\n- Shipped in Byzantium ([EIP-609](/eip-609/)).\n"},"ja":{"lang":"ja","tldr":"トランザクションレシート内の中間ステートルートをステータスコード（1 = 成功、0 = 失敗）に置き換え、すべてのクライアントがトランザクションの成否を確実に判定できるようにした。","tags":["receipts","transactions","core","byzantium"],"related":[140,609,2718,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-658/","markdown":"## 何を解決するのか\n\nByzantium 以前は、「トランザクションがガスを使い切ったら失敗」という経験則がよく使われていました。[EIP-140](/eip-140/) が `REVERT` オペコードを追加し、これは状態変更を取り消し、**残りのガスを返金**します。その後は、失敗したトランザクションが、安価な成功トランザクションのように見える可能性が出てきました。\n\nフルノードはトランザクションを再実行して何が起きたかを調べられます。ファストシンクしたノードにはそれができるのは最近のブロックだけで、ライトクライアントにはまったくできません。ウォレットや dapp には、結果がコンセンサスデータに記録されている必要がありました。\n\n## 仕組み\n\n以前、各レシートには**中間ステートルート**、つまりそのトランザクション直後のステートトライのルートが含まれていました。このフィールドは、先行する提案 EIP-98 によってすでに不要になっていました。\n\nByzantium フォーク以降は、このフィールドに代わって**ステータスコード**が入ります。\n\n- `1` は、トップレベルの呼び出しが成功し、その状態変更が適用されたことを意味します。\n- `0` は、`REVERT`、ガス切れ、無効なオペコードなど、トランザクションをリバートさせる何らかの理由で失敗したことを意味します。\n\nレシートには累積ガス使用量、ログブルーム、ログも引き続き含まれるため、変更は 1 つのフィールドだけです。レシートはブロックヘッダーのレシートルートにコミットされているため、ライトクライアントは Merkle 証明でステータスを検証できます。\n\n## サンプルコード\n\nRLP としてのレシート、変更前と変更後:\n\n```\npre-Byzantium:  [post_state_root (32 bytes), cumulative_gas_used, logs_bloom, logs]\npost-Byzantium: [status (0x01 or empty for 0), cumulative_gas_used, logs_bloom, logs]\n```\n\nステータスの確認（ethers v6）:\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst receipt = await provider.getTransactionReceipt(txHash);\n\nif (receipt?.status === 1) {\n  console.log(\"success\");\n} else if (receipt?.status === 0) {\n  console.log(\"reverted\");\n}\n```\n\nJSON-RPC では、`eth_getTransactionReceipt` が `\"status\": \"0x1\"` または `\"0x0\"` を返します。Byzantium 以前のレシートは、代わりに `root` フィールドを返します。\n\n## 知っておくべきこと\n\n- ステータスが表すのは**トップレベル**の呼び出しだけです。内部呼び出しが失敗してもコントラクトがその失敗を捕捉した場合、トランザクションは成功しえます。\n- ステータスが `0` でも、送信者は使用したガスの代金を支払っており、nonce は消費されています。\n- ステータスコードにはリバート理由や戻りデータは含まれません。それらは `eth_call` やトレースで読み取ってください。[EIP-211](/eip-211/) により、戻りデータが EVM 内で利用できるようになりました。\n- 型付きトランザクション（[EIP-2718](/eip-2718/)）も、レシートにステータスフィールドを保持します。\n- Byzantium（[EIP-609](/eip-609/)）で出荷されました。\n"},"ko":{"lang":"ko","tldr":"트랜잭션 영수증의 중간 상태 루트를 상태 코드(1 = 성공, 0 = 실패)로 대체해, 모든 클라이언트가 트랜잭션의 성공 여부를 안정적으로 알 수 있게 했다.","tags":["receipts","transactions","core","byzantium"],"related":[140,609,2718,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-658/","markdown":"## 어떤 문제를 해결하나요?\n\nByzantium 이전에는 \"트랜잭션이 가스를 전부 썼다면 실패한 것\"이라는 경험칙이 흔히 쓰였습니다. [EIP-140](/eip-140/)이 `REVERT` opcode를 추가했는데, 이는 상태 변경을 되돌리고 **남은 가스를 환불**합니다. 그 뒤로는 실패한 트랜잭션이 값싼 성공 트랜잭션처럼 보일 수 있게 되었습니다.\n\n풀 노드는 트랜잭션을 재실행해 무슨 일이 있었는지 알아낼 수 있습니다. 패스트 싱크한 노드는 최근 블록에 대해서만 가능했고, 라이트 클라이언트는 아예 할 수 없었습니다. 지갑과 dapp에는 결과가 합의 데이터에 기록되어 있어야 했습니다.\n\n## 어떻게 동작하나요?\n\n예전에는 각 영수증에 **중간 상태 루트**, 즉 해당 트랜잭션 직후의 상태 트라이 루트가 들어 있었습니다. 이 필드는 앞선 제안인 EIP-98에서 이미 불필요해졌습니다.\n\nByzantium 포크부터는 이 필드에 **상태 코드**가 들어갑니다.\n\n- `1`은 최상위 호출이 성공했고 그 상태 변경이 적용되었다는 뜻입니다.\n- `0`은 `REVERT`, 가스 부족, 잘못된 opcode처럼 트랜잭션을 되돌리는 어떤 이유로든 실패했다는 뜻입니다.\n\n영수증에는 누적 가스 사용량, 로그 블룸, 로그가 여전히 들어 있으므로 변경은 필드 하나뿐입니다. 영수증은 블록 헤더의 영수증 루트에 커밋되기 때문에, 라이트 클라이언트는 머클 증명으로 상태를 검증할 수 있습니다.\n\n## 샘플 코드\n\nRLP로 본 영수증, 변경 전과 후:\n\n```\npre-Byzantium:  [post_state_root (32 bytes), cumulative_gas_used, logs_bloom, logs]\npost-Byzantium: [status (0x01 or empty for 0), cumulative_gas_used, logs_bloom, logs]\n```\n\n상태 확인(ethers v6):\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst receipt = await provider.getTransactionReceipt(txHash);\n\nif (receipt?.status === 1) {\n  console.log(\"success\");\n} else if (receipt?.status === 0) {\n  console.log(\"reverted\");\n}\n```\n\nJSON-RPC에서 `eth_getTransactionReceipt`는 `\"status\": \"0x1\"` 또는 `\"0x0\"`을 반환합니다. Byzantium 이전의 영수증은 대신 `root` 필드를 반환합니다.\n\n## 알아둘 점\n\n- 상태는 **최상위** 호출만 나타냅니다. 내부 호출이 실패해도 컨트랙트가 그 실패를 처리했다면 트랜잭션은 성공할 수 있습니다.\n- 상태가 `0`이어도 발신자는 사용한 가스 비용을 지불했고 nonce는 소비됩니다.\n- 상태 코드에는 리버트 사유나 반환 데이터가 포함되지 않습니다. 이는 `eth_call`이나 트레이싱으로 읽으세요. [EIP-211](/eip-211/)로 반환 데이터를 EVM 안에서 사용할 수 있게 되었습니다.\n- 타입이 있는 트랜잭션([EIP-2718](/eip-2718/))도 영수증에 상태 필드를 유지합니다.\n- Byzantium([EIP-609](/eip-609/))에서 출시되었습니다.\n"},"zh":{"lang":"zh","tldr":"用状态码（1 = 成功，0 = 失败）取代交易收据中的中间状态根，使每个客户端都能可靠地判断一笔交易是否成功。","tags":["receipts","transactions","core","byzantium"],"related":[140,609,2718,211],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-658/","markdown":"## 它解决什么问题？\n\n在 Byzantium 之前，一种常见的经验判断是\"如果交易用光了所有 gas，就说明失败了\"。[EIP-140](/eip-140/) 增加了 `REVERT` 操作码，它会撤销状态更改，**并退还剩余的 gas**。此后，失败的交易可能看起来像一笔廉价的成功交易。\n\n全节点可以重放交易来查明发生了什么。快速同步的节点只能对近期区块这样做，轻客户端则完全做不到。钱包和 dapp 需要把结果记录在共识数据中。\n\n## 它如何运作\n\n过去每份收据都包含一个**中间状态根**：该交易执行完毕后的状态树根。这个字段此前已被早先的提案 EIP-98 废弃。\n\n从 Byzantium 分叉起，该字段改为存放**状态码**：\n\n- `1` 表示顶层调用成功，其状态更改已被应用。\n- `0` 表示因任何会导致交易回滚的原因而失败，例如 `REVERT`、gas 耗尽或无效操作码。\n\n收据仍然包含累计 gas 使用量、日志布隆过滤器和日志，因此变更仅涉及一个字段。由于收据已提交到区块头的收据根中，轻客户端可以用默克尔证明来验证状态。\n\n## 示例代码\n\nRLP 形式的收据，变更前后对比：\n\n```\npre-Byzantium:  [post_state_root (32 bytes), cumulative_gas_used, logs_bloom, logs]\npost-Byzantium: [status (0x01 or empty for 0), cumulative_gas_used, logs_bloom, logs]\n```\n\n检查状态（ethers v6）：\n\n```ts\nimport { JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst receipt = await provider.getTransactionReceipt(txHash);\n\nif (receipt?.status === 1) {\n  console.log(\"success\");\n} else if (receipt?.status === 0) {\n  console.log(\"reverted\");\n}\n```\n\n在 JSON-RPC 中，`eth_getTransactionReceipt` 返回 `\"status\": \"0x1\"` 或 `\"0x0\"`。Byzantium 之前的收据则返回 `root` 字段。\n\n## 需要注意\n\n- 状态只描述**顶层**调用。即使内部调用失败，只要合约捕获了该失败，交易仍可能成功。\n- 状态为 `0` 仍然意味着发送方为已用的 gas 付了费，nonce 也已被消耗。\n- 状态码不包含回滚原因或返回数据。请通过 `eth_call` 或追踪来读取这些信息。[EIP-211](/eip-211/) 使返回数据在 EVM 内部可用。\n- 类型化交易（[EIP-2718](/eip-2718/)）在其收据中保留状态字段。\n- 随 Byzantium（[EIP-609](/eip-609/)）发布。\n"}},"requiredBy":[609,6466]}
