Gnosis
trace_replayTransaction
The trace_replayTransaction method allows you to replay a transaction and retrieve a variety of trace information including execution trace, VM trace, and state changes. This method provides more detailed information than trace_transaction by showing how the transaction changed the state.
Use Cases
- Debugging complex transactions with state changes
- Analyzing gas consumption for optimization
- Tracing internal calls between contracts
- Understanding how storage was modified by a transaction
- Verifying the execution of complex logic flows
- Security auditing with full state transition detail
- Analyzing revert reasons with detailed context
- Investigating memory and storage access patterns
- Validating contract behavior as part of audit reviews
- Optimizing contract code based on execution patterns
Method Details
This method replays a transaction and returns detailed trace information including VM trace and state differences.
Response Example
Trace Types
The traceTypes parameter accepts an array of the following values:
- trace: The basic trace of transaction execution
- vmTrace: A detailed trace of the EVM execution
- stateDiff: State changes resulting from the transaction
You can request any combination of these trace types.
State Diff Format
The state diff format uses the following symbols:
- "=": No change in the value
- "+": The value was created
- "-": The value was deleted
- "*": The value was modified, with "from" and "to" values
Important Notes
- This method requires trace APIs to be enabled on the Ethereum node
- Not all Ethereum clients support this method (primarily OpenEthereum/Nethermind)
- The response can be very large, especially with vmTrace enabled
- For simple trace information without state changes, use
trace_transactioninstead - The method is computationally intensive and may take time to complete
- Historical transactions can only be traced if the node maintains archive data
- Different traceTypes significantly affect response size and computation time
- For debugging simpler transactions,
trace_transactionmay be sufficient - State diffs are particularly valuable for understanding storage changes
- Transactions that revert will show state changes up to the revert point
See also
- trace_transaction - Retrieve basic traces for a transaction
- trace_replayBlockTransactions - Replay and trace all transactions in a block
- trace_call - Execute and trace a call without creating a transaction
- debug_traceTransaction - Alternative detailed transaction tracing
Parameters
The hash of the transaction to replay
Array of trace types to include in the response (JSON)