Taiko
Taiko
trace_transaction
The trace_transaction method retrieves detailed trace information for a transaction identified by its hash. This method provides insight into every step of the transaction's execution, including internal calls between contracts, allowing for in-depth analysis and debugging.
Use Cases
- Debugging specific transactions to identify errors
- Analyzing gas consumption for individual operations
- Tracing internal calls within a transaction
- Understanding complex contract interactions
- Investigating transaction failures
- Security auditing and vulnerability analysis
- Verifying expected contract behavior
- Tracking funds flow across multiple contracts
- Analyzing execution patterns of similar transactions
- Debugging failed or reverted transactions
Method Details
This method returns an array of traces for all operations executed during the transaction.
Response Example
Understanding the Trace Tree
The trace tree represents the execution flow of the transaction:
- Root level trace: The main transaction (empty
traceAddress) - Subtrace level 1: Internal calls directly from the main transaction (
traceAddressof[0],[1], etc.) - Deeper levels: Subsequent internal calls (
traceAddressof[0, 0],[0, 1], etc.)
Call Types
The callType field may have different values:
- call: A regular message call
- delegatecall: A call where the code is executed in the context of the caller
- staticcall: A read-only call (no state modifications allowed)
- callcode: Similar to delegatecall but with the value passed (legacy)
Trace Types
The type field indicates the operation type:
- call: A message call
- create: A contract creation
- suicide: A contract self-destruct (SELFDESTRUCT opcode)
Important Notes
- This method requires trace APIs to be enabled on the Ethereum node
- The response can be very large for complex transactions with many internal calls
- The method is computationally intensive and may take time to complete for complex transactions
- Not all Ethereum clients support this method
- Historical transactions can only be traced if the node maintains archive data
- Some clients may have limitations on how far back transactions can be traced
- For more detailed VM-level execution traces, consider using
trace_replayTransaction - Unlike event logs, traces capture all contract interactions including those that don't emit events
- Failed transactions will still produce traces up to the point of failure
- SELFDESTRUCT operations appear with type "suicide" for historical reasons
See also
- trace_filter - Search for traces based on criteria
- trace_block - Retrieve traces for all transactions in a block
- trace_replayTransaction - Get more detailed traces with state changes
- debug_traceTransaction - Alternative detailed transaction tracing
Parameters
The hash of the transaction to trace