# debug_traceTransaction

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://eth-mainnet.g.alchemy.com/v2/{apiKey}

Attempts to run the transaction in the exact same manner as it was executed on the network.

Reference: https://www.alchemy.com/docs/node/debug-api/debug-api-endpoints/debug-trace-transaction

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Transaction hash | string | Yes | Hash of the transaction to be traced. |
| Options | object | No | Options for the call. |

## Result

**Transaction trace** (object[]): Trace for the transaction.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "debug_traceTransaction",
  "params": [
    "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": [
    {
      "name": "transaction trace",
      "value": {
        "type": "CALL",
        "from": "0xe088776deabb472ffd2843e330e79c880a5f979e",
        "to": "0x70526cc7a6d6320b44122ea9d2d07670accc85a1",
        "value": "0x0",
        "gas": "0x7fffffffffffadf7",
        "gasUsed": "0x0",
        "input": "0x",
        "output": "0x"
      }
    }
  ],
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://eth-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_traceTransaction",
  "params": [
    "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae",
    {
      "tracer": "callTracer",
      "tracerConfig": {
        "onlyTopCall": false
      },
      "timeout": "string"
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'debug_traceTransaction',
    params: [
      '0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae',
      {tracer: 'callTracer', tracerConfig: {onlyTopCall: false}, timeout: 'string'}
    ]
  })
};

fetch('https://eth-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "debug_traceTransaction",
    "params": [
        "0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae",
        {
            "tracer": "callTracer",
            "tracerConfig": { "onlyTopCall": False },
            "timeout": "string"
        }
    ]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://eth-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"debug_traceTransaction\",\n  \"params\": [\n    \"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\",\n    {\n      \"tracer\": \"callTracer\",\n      \"tracerConfig\": {\n        \"onlyTopCall\": false\n      },\n      \"timeout\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://eth-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"debug_traceTransaction\",\n  \"params\": [\n    \"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\",\n    {\n      \"tracer\": \"callTracer\",\n      \"tracerConfig\": {\n        \"onlyTopCall\": false\n      },\n      \"timeout\": \"string\"\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://eth-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"debug_traceTransaction\",\n  \"params\": [\n    \"0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae\",\n    {\n      \"tracer\": \"callTracer\",\n      \"tracerConfig\": {\n        \"onlyTopCall\": false\n      },\n      \"timeout\": \"string\"\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: debug_traceTransaction
description: Attempts to run the transaction in the exact same manner as it was executed on the network.
params:
  - name: Transaction hash
    required: true
    description: Hash of the transaction to be traced.
    schema:
      title: 32 byte hex value
      type: string
      pattern: ^0x[0-9a-f]{64}$
  - name: Options
    required: false
    description: Options for the call.
    schema:
      type: object
      properties:
        tracer:
          type: string
          enum:
            - callTracer
            - prestateTracer
        tracerConfig:
          type: object
          properties:
            onlyTopCall:
              type: boolean
        timeout:
          type: string
          description: A duration string that overrides the default timeout.
result:
  name: Transaction trace
  description: Trace for the transaction.
  schema:
    type: array
    description: Array of block traces.
    items:
      type: object
      description: Array of block traces.
      properties:
        type:
          type: string
          description: CALL or CREATE
        from:
          type: string
          description: 20-byte address of the caller
        to:
          type: string
          description: 20-byte address of the recipient. Null when its a contract creation transaction.
        value:
          type: string
          description: Amount of value included in the transfer (in hex)
        gas:
          type: string
          description: Amount of gas provided for the call (in hex)
        gasUsed:
          type: string
          description: Amount of gas used during the call (in hex)
        input:
          type: string
          description: Call data
        output:
          type: string
          description: Return data
        error:
          type: string
          description: Error message, if any.
        revertReason:
          type: string
          description: Solidity revert reason, if any.
        calls:
          type: array
          description: Array of sub-calls made within the transaction.
          items:
            type: object
            description: Array of block traces.
            properties:
              type:
                type: string
                description: CALL or CREATE
              from:
                type: string
                description: 20-byte address of the caller
              to:
                type: string
                description: 20-byte address of the recipient. Null when its a contract creation transaction.
              value:
                type: string
                description: Amount of value included in the transfer (in hex)
              gas:
                type: string
                description: Amount of gas provided for the call (in hex)
              gasUsed:
                type: string
                description: Amount of gas used during the call (in hex)
              input:
                type: string
                description: Call data
              output:
                type: string
                description: Return data
              error:
                type: string
                description: Error message, if any.
              revertReason:
                type: string
                description: Solidity revert reason, if any.
examples:
  - name: debug_traceTransaction example
    params:
      - name: Transaction hash
        value: '0x8fc90a6c3ee3001cdcbbb685b4fbe67b1fa2bec575b15b0395fea5540d0901ae'
    result:
      name: debug_traceTransaction response
      value:
        - name: transaction trace
          value:
            type: CALL
            from: '0xe088776deabb472ffd2843e330e79c880a5f979e'
            to: '0x70526cc7a6d6320b44122ea9d2d07670accc85a1'
            value: '0x0'
            gas: '0x7fffffffffffadf7'
            gasUsed: '0x0'
            input: 0x
            output: 0x
```
