Ethereum
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Ethereum
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
Give trace_replayTransaction the hash of a transaction that already landed on Ethereum, and the node re-runs it against the state that existed just before it executed, then returns whatever depth of detail you select. You choose any combination of three views: trace (the call tree), vmTrace (an opcode-by-opcode record), and stateDiff (every balance, nonce, code, and storage slot the transaction altered, marked with +, -, *, or =). It's the single-transaction member of the replay family on Ethereum mainnet (chain ID 1), where its block-wide sibling handles entire blocks. Replay requests go to https://ethereum.therpc.io/YOUR_API_KEY and require an archive node, since reconstructing the pre-transaction state means reaching back into history.
stateDiff lists each touched slot with its before and after value, which is what forensic work on a hack or a mispriced trade depends on.| # | 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|---|
| 1 | transactionHash | string | 是 | Hash of the transaction to replay. |
| 2 | traceTypes | array | 是 | One or more of `"trace"`, `"vmTrace"`, `"stateDiff"`. At least one value is required. |
| 类型 | 描述 |
|---|---|
| object | `{output, trace?, stateDiff?, vmTrace?}` — `trace` is the call tree, `stateDiff` maps each affected address to balance/nonce/code/storage diffs using `=` (unchanged), `+` (created), `-` (deleted), `*{from,to}` (modified), `vmTrace` is the Parity-format opcode trace. |
Try it live in the Ethereum playground.
| 错误码 | 错误信息 | 原因 |
|---|---|---|
-32601 | Method not found | trace namespace not enabled or not supported by this client (primarily OpenEthereum/Nethermind/Erigon). |
-32602 | Invalid params | Transaction hash is missing/malformed or traceTypes is empty or contains unknown values. |
-32000 | transaction not found | Transaction does not exist or archive trace data is unavailable for that block. |
vmTrace on a complex transaction (a multi-hop DEX route, a flash-loan unwind) generates an enormous opcode log. When you only need call structure or storage changes, stick to ["trace"] or ["stateDiff"].vmTrace is Parity-format, not Geth's structLog. If you're migrating from debug_traceTransaction, expect a different schema and adjust your decoder accordingly.参数
0x-prefixed 32-byte hash
["trace"] | ["trace","vmTrace","stateDiff"]