x402
它能做什么
这项技能涵盖 x402,这是一种让网络服务通过标准 HTTP 402 付款响应,按每次请求收费的方式。智能体可以解读付款请求、准备待签名的付款,并使用结算服务来验证或结算。
适用场景
- ✓当一项在线服务返回付款请求,而你的智能体需要付款时。
- ✓当你希望按每次请求向其他智能体收费,使用你自己的 API 时。
- ✓当你在批准付款之前,需要检查付款请求的时候。
技能链接
https://github.com/internet-court/internet-court-skill/blob/main/vendored/chaingpt/x402/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想让我的智能体为一个要求付款的 API 付款,但请先说明它要我付多少钱。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会读取付款请求,并用通俗的语言解释金额、币种和收款方。它会准备一笔未签名的付款,由你的钱包签名,然后智能体将其随请求一同发回。结算服务无法更改你签名的金额或收款方。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
x402 Payments skill
x402 turns HTTP 402 Payment Required into a real payment rail for agents: a
server replies 402 with what it wants paid; the client signs an off-chain
authorization and retries with an X-PAYMENT header; a facilitator broadcasts
it. Settlement uses EIP-3009 transferWithAuthorization (e.g. USDC on Base) —
the facilitator can only broadcast the signed authorization, never alter the
amount or destination.
Custody-free: the plugin builds the EIP-712 the payer signs and assembles the header; it never holds a key.
Tools
| Tool | Purpose |
|---|---|
chaingpt_x402_decode |
Decode a 402 body or X-PAYMENT header into human terms (amount/token/recipient/expiry) before paying. |
chaingpt_x402_build_payment |
Build the UNSIGNED EIP-3009 typed data; pass a signature back to get the final X-PAYMENT header. |
chaingpt_x402_facilitator |
Call a facilitator: supported / verify / settle. |
chaingpt_x402_create_requirements |
Server side: generate the PaymentRequirements + 402 body to monetize your endpoint. |
chaingpt_x402_fetch |
The whole client loop in one tool: fetch a URL; on 402 it decodes the challenge and (given from) emits the unsigned typed data; re-call with xPaymentHeader to complete the paid request. |
Pay an endpoint (client flow)
Fast path — one tool drives the loop:
chaingpt_x402_fetch url=<resource> from=<payer>→ on 402 you get the decoded price/payee AND the unsigned EIP-3009 typed data.- Sign the typed data in the payer's wallet.
chaingpt_x402_build_payment from=<payer> requirements=<from step 1> signature=0x…→ theX-PAYMENTheader.chaingpt_x402_fetch url=<resource> xPaymentHeader=<header>→ the paid response.
Manual path (same primitives, finer control): _decode → _build_payment → sign → _build_payment +signature → retry yourself.
Monetize your endpoint (server flow)
chaingpt_x402_create_requirements network=base amount=0.01 payTo=<you> → serve
the returned JSON with HTTP 402. Verify/settle incoming payments via a
facilitator (chaingpt_x402_facilitator).
Known EIP-3009 tokens: USDC on base and base-sepolia. For other tokens pass
full PaymentRequirements (with asset + extra.name/extra.version).
0 ChainGPT credits.
常见问题
智能体会持有我的钱包密钥吗?
不会。该技能说明智能体从不持有密钥,签名由你的钱包完成。
什么是结算服务?
它是一种检查已签名付款并将其发送到区块链的服务。
它使用哪种币?
该技能的示例使用 Base 网络上的 USDC。
详情
作者的原始描述
x402 agentic payments (Coinbase's HTTP 402 protocol). Custody-free tools to pay x402-protected endpoints (build the EIP-3009 transferWithAuthorization the payer signs, assemble the X-PAYMENT header), call a facilitator (verify/settle/supported), and monetize your own API by generating PaymentRequirements. USDC on Base. Triggers: x402, HTTP 402, pay per request, agentic payment, machine payment, X-PAYMENT, transferWithAuthorization, EIP-3009, facilitator, monetize API, pay for API, agent pays.
热度
- GitHub 星标
- 7.0k
- 排名
- #13623
- 许可证
- —
- 更新时间
- 2026/10/26
评论
- …
同一仓库的更多技能
internet-court
7.0k帮你的智能体安全地向其他 AI 智能体或付费服务付款、雇用或进行交易,并指引它找到合适的专业指南。
genlayer-erc7710-connector
7.0k帮你的智能体把 AI 审核结果与权限系统连接起来,使不合格的审核可以限制或取消智能体的权限。
genlayer-intelligent-contracts
7.0k帮你的智能体定义 AI 裁判的规则、证据和输出,用于检查另一个智能体是否遵循了其授权范围。
x402-erc7710
7.0k帮你的智能体按次为网络服务付款,并设置在权限预算范围内的持续支出。