支付服务:自动完成 x402 API 支付 - Openclaw Skills
作者:互联网
2026-03-26
什么是 支付服务?
支付服务技能使 AI 智能体能够通过 x402 协议自主处理付费 API 交互。通过利用 Openclaw Skills 和 Awal CLI,智能体可以向高级端点执行 GET 或 POST 请求,同时在 Base 网络上自动处理 USDC 支付。这消除了人工支付的摩擦,允许智能体以编程方式访问广泛的付费数字服务和数据集。
此技能对于开发需要消耗非免费资源的智能体的开发者至关重要。通过与 Awal 钱包系统集成,它确保每次 API 调用都由区块链上可验证的交易提供支持,为 Openclaw Skills 内部的机器对机器经济提供了一个强大的框架。
下载入口:https://github.com/openclaw/skills/tree/main/skills/0xrag/pay-for-service
安装与下载
1. ClawHub CLI
从源直接安装技能的最快方式。
npx clawhub@latest install pay-for-service
2. 手动安装
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
/skills/
优先级:工作区 > 本地 > 内置
3. 提示词安装
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 pay-for-service。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
支付服务 应用场景
- 触发付费 API 请求以获取高级数据,如实时金融反馈或专业 AI 模型。
- 为单个服务调用自动化微支付,无需人工干预。
- 通过为特定请求设置严格的最高支付金额来限制智能体支出。
- 将付费搜索或研究服务集成到复杂的多智能体工作流中。
- 智能体验证当前钱包身份验证状态,以确保其可以签署交易。
- 系统检查 USDC 余额,以确认是否有足够的资金用于预定请求。
- 用户或智能体提供符合 x402 标准的 URL 和任何必要的请求参数(方法、正文、请求头)。
- 技能执行 npx awal@latest x402 pay 命令,同时处理区块链交易和 HTTP 请求。
- 付费 API 响应返回给智能体以供进一步处理。
支付服务 配置指南
确保您已安装 Awal CLI,并且您的钱包在 Base 网络上有充足的 USDC。
# 检查钱包是否已通过身份验证
npx awal@latest status
# 检查 USDC 余额(需要了解原子单位)
npx awal@latest balance
支付服务 数据架构与分类体系
该技能利用特定参数来有效管理支付和 API 通信:
| 字段 | 描述 | 格式 |
|---|---|---|
| url | 目标 x402 API 端点 | 字符串 (URL) |
| max-amount | 该调用允许的最大 USDC 原子单位 | 整数 (1,000,000 = $1.00) |
| method | 请求使用的 HTTP 方法 | GET, POST, PUT, DELETE |
| data | 请求正文的 JSON 负载 | JSON 字符串 |
| correlation-id | 用于对相关操作进行分组的标识符 | 字符串 |
name: pay-for-service
description: Make a paid API request to an x402 endpoint with automatic USDC payment. Use when you or the user want to call a paid API, make an x402 request, use a paid service, or pay for an API call. Use after finding a service with search-for-service.
user-invocable: true
disable-model-invocation: false
allowed-tools: ["Bash(npx awal@latest status*)", "Bash(npx awal@latest balance*)", "Bash(npx awal@latest x402 pay *)"]
Making Paid x402 Requests
Use the npx awal@latest x402 pay command to call paid API endpoints with automatic USDC payment on Base.
Confirm wallet is initialized and authed
npx awal@latest status
If the wallet is not authenticated, refer to the authenticate-wallet skill.
Command Syntax
npx awal@latest x402 pay [-X ] [-d ] [-q ] [-h ] [--max-amount ] [--json]
Options
| Option | Description |
|---|---|
-X, --method |
HTTP method (default: GET) |
-d, --data |
Request body as JSON string |
-q, --query |
Query parameters as JSON string |
-h, --headers |
Custom HTTP headers as JSON string |
--max-amount |
Max payment in USDC atomic units (1000000 = $1.00) |
--correlation-id |
Group related operations |
--json |
Output as JSON |
USDC Amounts
X402 uses USDC atomic units (6 decimals):
| Atomic Units | USD |
|---|---|
| 1000000 | $1.00 |
| 100000 | $0.10 |
| 50000 | $0.05 |
| 10000 | $0.01 |
IMPORTANT: Always single-quote amounts that use $ to prevent bash variable expansion (e.g. '$1.00' not $1.00).
Examples
# Make a GET request (auto-pays)
npx awal@latest x402 pay https://example.com/api/weather
# Make a POST request with body
npx awal@latest x402 pay https://example.com/api/sentiment -X POST -d '{"text": "I love this product"}'
# Limit max payment to $0.10
npx awal@latest x402 pay https://example.com/api/data --max-amount 100000
Prerequisites
- Must be authenticated (
npx awal@latest statusto check, seeauthenticate-walletskill) - Wallet must have sufficient USDC balance (
npx awal@latest balanceto check) - If you don't know the endpoint URL, use the
search-for-serviceskill to find services first
Error Handling
- "Not authenticated" - Run
awal auth loginfirst, or seeauthenticate-walletskill - "No X402 payment requirements found" - URL may not be an x402 endpoint; use
search-for-serviceto find valid endpoints - "Insufficient balance" - Fund wallet with USDC; see
fundskill
相关推荐
专题
+ 收藏
+ 收藏
+ 收藏
+ 收藏
+ 收藏
最新数据
相关文章
小红书文案教练:爆款笔记生成器 - Openclaw Skills
慕尼黑 MVG & S-Bahn 实时追踪命令行工具 - Openclaw Skills
Reddit 研究技能:自动化社群洞察 - Openclaw Skills
豆包聊天:带有联网搜索功能的免费 AI 对话 - Openclaw Skills
NightPatch:自动化工作流优化 - Openclaw 技能
国产 AI 视频生成器:Wan2.6 与可灵集成 - Openclaw Skills
Sonos Announce:智能音频状态恢复 - Openclaw Skills
Hypha Payment:P2P 代理协作与 USDT 结算 - Openclaw Skills
Cashu Emoji:隐藏代币编解码 - Openclaw Skills
技术 SEO 精通:审计、修复与监控 - Openclaw Skills
AI精选
