> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blockx.chaintable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 同步调用与调试

> 直接检查一次 EVM 函数调用，无需提交任务。

使用 Sync Invoker 执行一次用户函数，并在同一次 RPC 中取得结果。与[编写 EVM 数据函数](/zh/guides/write-functions)一样，显式传入链与区块参数。

## 前置条件

按所在环境的连接与认证方式，将 gRPC 客户端连接到可用的 Sync Invoker。服务定义位于 BlockX 仓库的 `api/grpc/syncinvoker/sync_invoker.proto`。EVM 函数还需要对应节点后端。

## 检查并调用

1. 静态审计可用时，将函数源码提交给 `Precheck`。读取返回的检查结果；该操作不执行函数。
2. 恰好选择一个函数来源：注册函数使用 `function_id`，inline Python 使用 `inline_source.source_code`。
3. 将位置参数编码为 JSON 数组，写入 `args_json`。余额示例需要链、具体区块标识、代币和持有人。
4. 调用 `Invoke` 取得值；还需要捕获输出时，使用 `DebugInvoke`。
5. 检查 `success`。成功时解码 `result_json`，失败时检查 `failure`。

## 确认结果

将 `call_id` 与查询的链、区块一起记录。`DebugInvoke` 可在 `debug_output` 中返回有长度限制的 stdout/stderr 尾部及失败诊断。该入口不运行任务 Writer Plugin。

## 处理失败

| 结果 | 下一步 |
| - | - |
| Precheck 检查结果 | 修正函数后再调用 |
| RPC 错误 | 检查请求、连接与服务就绪状态 |
| `success=false` | 检查 `failure.code`、`failure.message` 和 `failure.retryable` |
| 值不符合预期 | 重新核对区块上下文、合约和方法参数 |

## 继续阅读

* [服务 API 参考](/zh/reference/service-api)
* [Sync Invoker](/zh/components/sync-invoker)
* [函数代码](/zh/concepts/function-code)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.