> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# trace_replayTransaction | Tempo

> Tempo API method that replays a specific transaction and returns detailed execution traces. trace_replayTransaction on Tempo via Chainstack.

Tempo API method that replays a specific transaction and returns detailed execution traces. This is useful for debugging transaction behavior with customizable trace options.

## Parameters

* `transactionHash` — the hash of the transaction to replay
* `traceTypes` — array of trace types to include:
  * `trace` — basic execution trace
  * `vmTrace` — full VM execution trace
  * `stateDiff` — state changes

## Response

* `result` — trace result object:
  * `output` — return data from the transaction
  * `trace` — array of trace objects (if requested)
  * `vmTrace` — VM execution trace (if requested)
  * `stateDiff` — state differences (if requested)

## `trace_replayTransaction` code examples

<CodeGroup>
  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const replayTransaction = async (txHash) => {
      // Replay with all trace types
      const result = await provider.send("trace_replayTransaction", [
        txHash,
        ["trace", "stateDiff"]
      ]);

      console.log("Transaction Output:", result.output);
      console.log("Traces:", result.trace?.length || 0);

      if (result.trace) {
        for (const trace of result.trace) {
          const callType = trace.action.callType || trace.type;
          const to = trace.action.to || "Contract Creation";
          console.log(`  ${callType}: ${trace.action.from} -> ${to}`);
        }
      }

      if (result.stateDiff) {
        console.log("\nState changes:");
        for (const [address, diff] of Object.entries(result.stateDiff)) {
          console.log(`  ${address}:`);
          if (diff.balance) {
            console.log(`    Balance: ${diff.balance['*']?.from || 'new'} -> ${diff.balance['*']?.to || diff.balance['+']}`);
          }
        }
      }
    };

  replayTransaction("0xb3e821e696897b02283b7b2d602941b1d3cb08448d3a204bab05955215fc2035");
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3

  node_url = "CHAINSTACK_NODE_URL"
  web3 = Web3(Web3.HTTPProvider(node_url))

  result = web3.provider.make_request("trace_replayTransaction", [
      "0xb3e821e696897b02283b7b2d602941b1d3cb08448d3a204bab05955215fc2035",
      ["trace", "stateDiff"]
  ])

  trace_result = result['result']
  print(f"Transaction Output: {trace_result['output']}")
  print(f"Traces: {len(trace_result.get('trace', []))}")

  for trace in trace_result.get('trace', []):
      call_type = trace['action'].get('callType', trace['type'])
      to = trace['action'].get('to', 'Contract Creation')
      print(f"  {call_type}: {trace['action']['from']} -> {to}")

  if trace_result.get('stateDiff'):
      print("\nState changes:")
      for address, diff in trace_result['stateDiff'].items():
          print(f"  {address}")
  ```

  ```bash cURL theme={"system"}
  curl -X POST "CHAINSTACK_NODE_URL" \
    -H "Content-Type: application/json" \
    -d '{
      "jsonrpc": "2.0",
      "method": "trace_replayTransaction",
      "params": ["0xb3e821e696897b02283b7b2d602941b1d3cb08448d3a204bab05955215fc2035", ["trace", "stateDiff"]],
      "id": 1
    }'
  ```
</CodeGroup>


## OpenAPI

````yaml openapi/tempo_node_api/debug_and_trace/trace_replayTransaction.json POST /
openapi: 3.0.0
info:
  title: trace_replayTransaction Tempo example
  version: 1.0.0
  description: This is an API example for trace_replayTransaction for Tempo.
servers:
  - url: https://tempo-mainnet.core.chainstack.com/c3ce2925b51f1ed18719fe8a23bbdccf
security: []
paths:
  /:
    post:
      tags:
        - Debug and trace
      summary: trace_replayTransaction
      operationId: tempo-trace-replayTransaction
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: trace_replayTransaction
                params:
                  type: array
                  items: {}
                  default:
                    - >-
                      0xb3e821e696897b02283b7b2d602941b1d3cb08448d3a204bab05955215fc2035
                    - - trace
                  description: Transaction hash and trace types array
                id:
                  type: integer
                  default: 1
      responses:
        '200':
          description: Replayed transaction trace
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: object
                    description: >-
                      Trace result object with output, trace, vmTrace, and
                      stateDiff

````