# trace_call

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

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

Executes a call and returns one or more possible traces.

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

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| transaction | object | Yes | Transaction call object. Contains call parameters such as "from", "to", "gas", "gasPrice", "value", and "data".  |
| traceTypes | enum[] | Yes | Array of trace types to return. Valid values include "trace" and "stateDiff".  |
| blockIdentifier | string | No | Optional block identifier (block number in hex, block hash, or tag like "latest").  |

## Result

**Trace Object** (object): Returns the trace result for the given call.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "trace_call",
  "params": [
    {
      "from": "0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638",
      "to": "0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e",
      "value": "0x0",
      "data": "0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000"
    },
    [
      "trace"
    ],
    "latest"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "jsonrpc": "2.0",
    "id": 0,
    "result": {
      "output": "0x",
      "stateDiff": "",
      "trace": [
        {
          "name": "trace item",
          "value": {
            "action": {
              "callType": "call",
              "from": "0x6f1fb6efdf50f34bfa3f2bc0e5576edd71631638",
              "gas": "0x1dcd11f8",
              "input": "0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000",
              "to": "0x1e0447b19bb6ecfdae1e4ae1694b0C3659614e4e",
              "value": "0x0"
            },
            "error": "Reverted",
            "subtraces": "0",
            "traceAddress": [],
            "type": "call"
          }
        }
      ],
      "vmTrace": null
    }
  },
  "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": "trace_call",
  "params": [
    {
      "from": "0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638",
      "to": "0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e",
      "value": "0x0",
      "data": "0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000"
    },
    [
      "trace"
    ],
    "latest"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'trace_call',
    params: [
      {
        from: '0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638',
        to: '0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e',
        value: '0x0',
        data: '0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000'
      },
      ['trace'],
      'latest'
    ]
  })
};

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": "trace_call",
    "params": [
        {
            "from": "0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638",
            "to": "0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e",
            "value": "0x0",
            "data": "0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000"
        },
        ["trace"],
        "latest"
    ]
}
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\": \"trace_call\",\n  \"params\": [\n    {\n      \"from\": \"0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638\",\n      \"to\": \"0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e\",\n      \"value\": \"0x0\",\n      \"data\": \"0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000\"\n    },\n    [\n      \"trace\"\n    ],\n    \"latest\"\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\": \"trace_call\",\n  \"params\": [\n    {\n      \"from\": \"0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638\",\n      \"to\": \"0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e\",\n      \"value\": \"0x0\",\n      \"data\": \"0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000\"\n    },\n    [\n      \"trace\"\n    ],\n    \"latest\"\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\": \"trace_call\",\n  \"params\": [\n    {\n      \"from\": \"0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638\",\n      \"to\": \"0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e\",\n      \"value\": \"0x0\",\n      \"data\": \"0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000\"\n    },\n    [\n      \"trace\"\n    ],\n    \"latest\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: trace_call
description: Executes a call and returns one or more possible traces.
params:
  - name: transaction
    required: true
    description: |
      Transaction call object. Contains call parameters such as "from", "to", "gas", "gasPrice", "value", and "data".
    schema:
      type: object
      properties:
        from:
          title: hex encoded address
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
        to:
          title: hex encoded address
          type: string
          pattern: ^0x[0-9a-fA-F]{40}$
        gas:
          type: string
        gasPrice:
          type: string
        value:
          type: string
        data:
          type: string
  - name: traceTypes
    required: true
    description: |
      Array of trace types to return. Valid values include "trace" and "stateDiff".
    schema:
      type: array
      items:
        type: string
        enum:
          - trace
          - stateDiff
  - name: blockIdentifier
    required: false
    description: |
      Optional block identifier (block number in hex, block hash, or tag like "latest").
    schema:
      type: string
result:
  name: Trace Object
  description: Returns the trace result for the given call.
  schema:
    type: object
    properties:
      output:
        type: string
      stateDiff:
        type: string
        nullable: true
      trace:
        type: array
        items:
          type: object
          properties:
            action:
              type: object
            error:
              type: string
              nullable: true
            subtraces:
              type: integer
            traceAddress:
              type: array
              items:
                type: string
            type:
              type: string
      vmTrace:
        type: string
        nullable: true
examples:
  - name: trace_call example
    params:
      - name: transaction
        value:
          from: '0x6f1FB6EFDf50F34bFA3F2bC0E5576EdD71631638'
          to: '0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e'
          value: '0x0'
          data: '0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000'
      - name: traceTypes
        value:
          - trace
      - name: blockIdentifier
        value: latest
    result:
      name: trace_call response
      value:
        jsonrpc: '2.0'
        id: 0
        result:
          output: 0x
          stateDiff: ''
          trace:
            - name: trace item
              value:
                action:
                  callType: call
                  from: '0x6f1fb6efdf50f34bfa3f2bc0e5576edd71631638'
                  gas: '0x1dcd11f8'
                  input: '0xa67a6a45000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000'
                  to: '0x1e0447b19bb6ecfdae1e4ae1694b0C3659614e4e'
                  value: '0x0'
                error: Reverted
                subtraces: '0'
                traceAddress: []
                type: call
          vmTrace: null
```
