# trace_replayTransaction - Tempo RPC Method

Replays a transaction on Tempo and returns the requested traces.

This method requires an archive node. It is not available on full nodes.

## When to Use This Method

- **Replay and trace a transaction execution** - Get vmTrace, stateDiff, and trace in a single call for comprehensive analysis on Tempo
- **State diff extraction** - See exact account balance, nonce, code, and storage changes caused by a transaction for merchant settlement, treasury operations, payout automation, and stablecoin-native financial applications
- **VM trace debugging** - Get opcode-level execution details alongside the structured call trace
- **Comprehensive transaction analysis** - Combine all three trace types in one request for complete execution visibility

## Best Practices

- Returns more detailed trace data than debug\_traceTransaction
- Combine vmTrace with trace array for a full picture of opcode and call-level execution
- Request all three trace types (trace, vmTrace, stateDiff) for maximum detail
- Requires archive node access; not available on standard full nodes

## Request Parameters

- `txHash` (`DATA, required`): 32-byte transaction hash
- `traceTypes` (`Array, required`): Trace types: ["trace"], ["vmTrace"], ["stateDiff"], or combinations

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "trace_replayTransaction",
  "params": ["0x50b1857dce8dbe401e09610534de81655bc508c6765eb30ecefe24148c515c28", ["trace"]],
  "id": 1
}
```

## Response Fields

This method returns no documented fields.

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {}
}
```

## Code Examples

cURL
JavaScript
Python

```bash
curl -X POST https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "trace_replayTransaction",
    "params": ["0x50b1857dce8dbe401e09610534de81655bc508c6765eb30ecefe24148c515c28", ["trace"]],
    "id": 1
  }'
```

```javascript
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY');

const result = await provider.send('trace_replayTransaction', [
  '0x50b1857dce8dbe401e09610534de81655bc508c6765eb30ecefe24148c515c28',
  ['trace']
]);
console.log('Trace:', result.trace.length, 'entries');
console.log('State diff:', result.stateDiff ? 'present' : 'not requested');
```

```python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY'))

result = w3.provider.make_request('trace_replayTransaction', [
    '0x50b1857dce8dbe401e09610534de81655bc508c6765eb30ecefe24148c515c28',
    ['trace']
])
trace = result['result']
print(f'Trace entries: {len(trace["trace"])}')
```

## Related Methods

- [`trace_replayBlockTransactions`](https://www.dwellir.com/docs/tempo/trace_replayBlockTransactions) - Replay all transactions in a block
- [`trace_transaction`](https://www.dwellir.com/docs/tempo/trace_transaction) - Get traces without replay
- [`trace_block`](https://www.dwellir.com/docs/tempo/trace_block) - Get all traces in a block
