---
title: "debug_traceCall"
description: "Trace 一个不会提交上链的 call（BSC）"
url: "https://blockreq.com/docs/zh-cn/build/api-reference/bsc/debug_traceCall/"
---

# debug_traceCall

**网络：** BSC · 主网 · Chain ID `56`（`0x38`）

**计为 5 个 Request。** 计费规则见 [Request Counting](https://blockreq.com/docs/zh-cn/pricing/request-counting/index.md)。

`debug_traceCall` 在指定区块上下文中执行 call，并返回执行 trace。它是付费 debug 方法，Free 不可用。历史区块上下文需要该链提供历史状态。

## 参数

1. `Object` - Call object，可包含 `from`、`to`、`gas`、`gasPrice`、`value`、`data`。
2. `QUANTITY|TAG` - 区块号或 tag。
3. `Object` - 可选 tracer 配置，例如 `{ "tracer": "callTracer" }`。

## 请求

```json
{
  "jsonrpc": "2.0",
  "method": "debug_traceCall",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000000",
      "data": "0x"
    },
    "latest",
    {
      "tracer": "callTracer"
    }
  ],
  "id": 1
}
```

## 说明

- Free 端点不可用。
- Tracer 支持情况取决于链。
- 旧区块执行上下文需要该链提供历史状态。

## 代码示例

**cURL**

```bash
curl -X POST https://bsc-rpc.blockreq.com/v1/rpc/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"debug_traceCall","params":[{"to":"0x0000000000000000000000000000000000000000","data":"0x"},"latest",{"tracer":"callTracer"}],"id":1}'
```

**TypeScript**

```typescript
const response = await fetch("https://bsc-rpc.blockreq.com/v1/rpc/public", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "method": "debug_traceCall",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000000",
      "data": "0x"
    },
    "latest",
    {
      "tracer": "callTracer"
    }
  ],
  "id": 1
}),
});
const data = await response.json();
console.log(data.result);
```

**Python**

```python
import requests

response = requests.post(
    "https://bsc-rpc.blockreq.com/v1/rpc/public",
    json={
  "jsonrpc": "2.0",
  "method": "debug_traceCall",
  "params": [
    {
      "to": "0x0000000000000000000000000000000000000000",
      "data": "0x"
    },
    "latest",
    {
      "tracer": "callTracer"
    }
  ],
  "id": 1
}
)
print(response.json()["result"])
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{"jsonrpc":"2.0","method":"debug_traceCall","params":[{"to":"0x0000000000000000000000000000000000000000","data":"0x"},"latest",{"tracer":"callTracer"}],"id":1}`)
	resp, err := http.Post(
		"https://bsc-rpc.blockreq.com/v1/rpc/public",
		"application/json",
		bytes.NewBuffer(payload),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result map[string]interface{}
	json.Unmarshal(body, &result)
	fmt.Println(result["result"])
}
```

**viem**

```typescript
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  transport: http("https://bsc-rpc.blockreq.com/v1/rpc/public"),
});

const result = await client.request({
  method: "debug_traceCall",
  params: [{"to":"0x0000000000000000000000000000000000000000","data":"0x"},"latest",{"tracer":"callTracer"}],
});
console.log(result);
```

**Foundry**

```bash
cast rpc --rpc-url https://bsc-rpc.blockreq.com/v1/rpc/public debug_traceCall {"to":"0x0000000000000000000000000000000000000000","data":"0x"} latest {"tracer":"callTracer"}
```

**Hardhat**

```javascript
const { ethers } = require("hardhat");

async function main() {
  const provider = new ethers.JsonRpcProvider("https://bsc-rpc.blockreq.com/v1/rpc/public");
  const result = await provider.send("debug_traceCall", [{"to":"0x0000000000000000000000000000000000000000","data":"0x"},"latest",{"tracer":"callTracer"}]);
  console.log(result);
}

main();
```
