> For the complete documentation index, see [llms.txt](https://docs.goassay.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.goassay.ai/developers/zh/shi-yong-gong-ju-ru-men/how-paying-works.md).

# 付费流程

启用付费调用，了解 assay-mcp 在每次付款签名前会检查什么。

[安装并登录](/developers/zh/shi-yong-gong-ju-ru-men/install-assay-mcp.md)后，免费调用会转发到 Assay。付费调用需要电脑上的支付密钥，以及钱包批准的支出权限。付款使用 **Robinhood Chain** 上的 **USDG**。

安全模型：Assay 服务器从不持有支付私钥；以你的操作系统用户身份运行的程序可能在链上上限内使用该密钥。

## 启用首次付费调用

首次尝试付费时，`assay-mcp` 会在本地创建支付密钥，存入操作系统密钥链，并在证明所有权后，将公钥地址注册到智能体的连接。工具结果会返回一个以 `#key=…` 结尾的启用付费链接。打开该链接，按需为托管余额充值，然后在钱包中批准该密钥。[开启付费调用](https://docs.goassay.ai/use-tools/zh/turn-on-paid-calls)逐一介绍了每个界面。之后请客户端重新进行付费调用；设置时的尝试不会完成该调用。

{% hint style="danger" %}
批准页面会显示 **Payment key** 指纹：密钥公钥地址的最后八个十六进制字符，分为两组。只有与客户端显示的指纹一致时才批准。如果不同，请勿批准；从客户端重新打开链接。
{% endhint %}

首次尝试付费后，若要重新打开批准页面，请运行：

```sh
npx -y @goassay-ai/mcp enable-paid
```

此命令打开现有密钥的链接，不会创建密钥。

## 每次付费调用会发生什么

客户端会转发工具调用。如果 Assay 返回付款请求，`assay-mcp` 会先检查再签名。任何检查失败或无法读取，都不会生成付款签名。

| 检查项        | 必须满足的条件                                                             |
| ---------- | ------------------------------------------------------------------- |
| 有真实调用正在等待  | 请求对应本进程刚转发的工具调用，且使用受支持的付款格式。调用尚未取消。                                 |
| 目标和币种正确    | 网络、托管目标地址、USDG 资产和小数精度与内置部署一致。金额是有效的正数。                             |
| 报价         | 该工具有同一资产的报价，请求金额不高于报价。                                              |
| 付款方和密钥已获授权 | 如果记录了账户，付款方必须与其一致。链上确认此电脑的密钥权限有效且未过期。服务器接受该密钥的签名，且指定的是同一个密钥。        |
| 链上状态一致     | 内置 RPC 端点返回一致结果。链上读取结果足够新；无法读取、结果过旧或相互冲突都会阻止签名。                     |
| 支出上限       | 金额符合密钥和账户的链上单次调用上限、本地单次调用上限，以及本地过去 24 小时的累计限额。兑付付款时，链上也会执行链上支出窗口上限。 |
| 提供方和服务器获准  | 提供方地址有效，并符合本地提供方限制（如有）。此服务器 URL 已获准进行付费调用；登录后默认允许 `/`。              |
| 请求字段有效     | 序号、请求哈希、资源和超时的格式与范围均有效。资源必须准确指向所调用的工具，不能是其他工具或账户欠款操作。               |
| 已确认（若启用）   | 金额超过本地确认阈值时，你需在客户端批准这笔确切的付款。默认关闭确认。                                 |

检查通过后，代理会将金额计入本地预算，并签署 EIP-712 付款授权。签名涵盖内置链和托管合约上的付款方、提供方、金额、工具资源、请求哈希、序号和有效时间。代理随后再次发送工具调用，并附上授权。

它**每次工具调用最多只为一笔付款签名**。同一次调用的第二个付款请求会原样返回，不予签名。

## 确认是否成功

客户端返回付费工具的结果，不再附带设置链接。超出本地限额的调用会在签名前被拒绝。

## 错误

| 原因        | 含义                   | 解决方法                   |
| --------- | -------------------- | ---------------------- |
| 支付密钥不匹配   | 批准链接中的密钥不是为此连接注册的密钥。 | 请勿批准；从客户端重新打开完整链接。     |
| 无法确认链上状态  | 代理无法验证密钥权限。          | 等到可以读取链上状态并确认权限后，再次请求。 |
| 金额超过上限或报价 | 付款超出适用限制。            | 选择符合默认限额和报价的工具。        |

## 延伸阅读

* 使用工具：[开启付费调用](https://docs.goassay.ai/use-tools/zh/turn-on-paid-calls)

## 下一步

* [支出限额](/developers/zh/shi-yong-gong-ju-ru-men/spending-limits.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.goassay.ai/developers/zh/shi-yong-gong-ju-ru-men/how-paying-works.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
