pay-for-service
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMaking Paid x402 Requests
发起付费x402请求
Use the command to call paid API endpoints with automatic USDC payment on Base.
npx awal@latest x402 pay使用命令在Base网络上调用带有自动USDC支付的付费API端点。
npx awal@latest x402 payConfirm wallet is initialized and authed
确认钱包已初始化并完成认证
bash
npx awal@latest statusIf the wallet is not authenticated, refer to the skill.
authenticate-walletbash
npx awal@latest status如果钱包未认证,请参考技能。
authenticate-walletCommand Syntax
命令语法
bash
npx awal@latest x402 pay <url> [-X <method>] [-d <json>] [-q <params>] [-h <json>] [--max-amount <n>] [--json]bash
npx awal@latest x402 pay <url> [-X <method>] [-d <json>] [-q <params>] [-h <json>] [--max-amount <n>] [--json]Options
选项
| Option | Description |
|---|---|
| HTTP method (default: GET) |
| Request body as JSON string |
| Query parameters as JSON string |
| Custom HTTP headers as JSON string |
| Max payment in USDC atomic units (1000000 = $1.00) |
| Group related operations |
| Output as JSON |
| 选项 | 描述 |
|---|---|
| HTTP方法(默认:GET) |
| 请求体(JSON字符串格式) |
| 查询参数(JSON字符串格式) |
| 自定义HTTP头(JSON字符串格式) |
| 最大支付金额(USDC原子单位,1000000 = 1.00美元) |
| 分组相关操作 |
| 以JSON格式输出 |
USDC Amounts
USDC金额
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. not ).
$'$1.00'$1.00x402使用USDC原子单位(6位小数):
| 原子单位 | 美元 |
|---|---|
| 1000000 | $1.00 |
| 100000 | $0.10 |
| 50000 | $0.05 |
| 10000 | $0.01 |
重要提示:对于包含的金额,请始终使用单引号包裹,以避免bash变量展开(例如使用而非)。
$'$1.00'$1.00Examples
示例
bash
undefinedbash
undefinedMake a GET request (auto-pays)
发起GET请求(自动支付)
npx awal@latest x402 pay https://example.com/api/weather
npx awal@latest x402 pay https://example.com/api/weather
Make a POST request with body
发起带请求体的POST请求
npx awal@latest x402 pay https://example.com/api/sentiment -X POST -d '{"text": "I love this product"}'
npx awal@latest x402 pay https://example.com/api/sentiment -X POST -d '{"text": "I love this product"}'
Limit max payment to $0.10
将最大支付金额限制为0.10美元
npx awal@latest x402 pay https://example.com/api/data --max-amount 100000
undefinednpx awal@latest x402 pay https://example.com/api/data --max-amount 100000
undefinedPrerequisites
前提条件
- Must be authenticated (to check, see
npx awal@latest statusskill)authenticate-wallet - Wallet must have sufficient USDC balance (to check)
npx awal@latest balance - If you don't know the endpoint URL, use the skill to find services first
search-for-service
- 必须已完成认证(使用检查,参考
npx awal@latest status技能)authenticate-wallet - 钱包必须有足够的USDC余额(使用检查)
npx awal@latest balance - 若不知道端点URL,请先使用技能查找服务
search-for-service
Error Handling
错误处理
- "Not authenticated" - Run first, or see
awal auth login <email>skillauthenticate-wallet - "No X402 payment requirements found" - URL may not be an x402 endpoint; use to find valid endpoints
search-for-service - "Insufficient balance" - Fund wallet with USDC; see skill
fund
- "Not authenticated" - 先运行,或参考
awal auth login <email>技能authenticate-wallet - "No X402 payment requirements found" - 该URL可能不是x402端点;使用查找有效端点
search-for-service - "Insufficient balance" - 为钱包充值USDC;参考技能
fund