# trace_replayTransaction - Taiko RPC Method

Replays a transaction on Taiko 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 Taiko
- **State diff extraction** - See exact account balance, nonce, code, and storage changes caused by a transaction for Taiko mainnet
- **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": ["0xc9aac5d30a3a9eb839f10db814a2cbe8971212bd8c77f8227d30532873be7bbe", ["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-taiko-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "trace_replayTransaction",
    "params": ["0xc9aac5d30a3a9eb839f10db814a2cbe8971212bd8c77f8227d30532873be7bbe", ["trace"]],
    "id": 1
  }'
```

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

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

const result = await provider.send('trace_replayTransaction', [
  '0xc9aac5d30a3a9eb839f10db814a2cbe8971212bd8c77f8227d30532873be7bbe',
  ['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-taiko-mainnet.n.dwellir.com/YOUR_API_KEY'))

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

## Related Methods

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