返回顶部
x

xclaw02x402支付

Make x402 payments. Pay for APIs, sell your services, handle 402 Payment Required responses with USDC on Base and other EVM chains.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.0
安全检测
已通过
1,491
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

xclaw02

xClaw02

您进入x402的入口——面向代理网络的开放支付标准。

x402是一个开放协议,支持通过HTTP使用402 Payment Required状态码进行即时稳定币支付。由Primer构建的xClaw02,为代理友好的CLI工具和简单API提供了收发支付的能力。

何时使用此技能

在以下情况使用xClaw02:

  • - 遇到402 Payment Required HTTP响应时
  • 需要访问付费API或资源
  • 用户要求您使用加密货币/USDC支付某物
  • 需要检查钱包余额或管理支付时
  • 想要为自己的API或服务收费

如何响应

用户说/问操作
我收到了402错误这是x402支付请求。使用xclaw02 probe <url>探测URL,显示价格,询问是否要支付
为这个API付费
使用xclaw02 pay --max-amount - 务必先与用户确认金额 | | 检查我的余额 | 运行xclaw02 wallet balance
| | 设置x402 / 设置支付 | 运行xclaw02 openclaw init | | 你们支持哪些网络? | 列出支持的网络(Base为主;还有Ethereum、Arbitrum、Optimism、Polygon) | | X多少钱? | 使用xclaw02 probe 探测URL获取定价 | | 创建一个钱包 | 运行xclaw02 wallet create - 提醒用户安全保存私钥 | | 我想为我的API收费 | 展示Express.js或FastAPI中间件示例 |

快速设置

Node.js

bash npx xclaw02 openclaw init

Python

bash pip install xclaw02 xclaw02 openclaw init

这将:

  1. 1. 创建一个新钱包(或使用现有钱包)
  2. 将配置保存到~/.openclaw/skills/xclaw02/
  3. 显示您的钱包地址,用于在Base上存入USDC

x402工作原理

  1. 1. 请求 - 您调用付费API
  2. 402响应 - 服务器在头部返回支付要求
  3. 支付并重试 - 签名支付,使用PAYMENT-SIGNATURE头部重试请求
  4. 访问 - 服务器验证支付,链上结算,返回资源

支付对付款方无gas费用 - 促进者处理gas费用。

CLI命令

命令描述
xclaw02 openclaw init为此代理设置xClaw02
xclaw02 openclaw status
检查设置状态和余额 | | xclaw02 probe | 检查URL是否需要支付并获取价格 | | xclaw02 pay | 支付资源(需要XCLAW02PRIVATEKEY) | | xclaw02 pay --dry-run | 预览支付而不实际支付 | | xclaw02 pay --max-amount 0.10 | 设置消费限额支付 | | xclaw02 wallet create | 创建新钱包 | | xclaw02 wallet balance
| 检查Base上的USDC余额 | | xclaw02 wallet from-mnemonic | 从助记词恢复钱包 | | xclaw02 networks | 列出支持的网络 |

CLI输出示例

bash
$ xclaw02 probe https://api.example.com/paid
{
status: payment_required,
price: 0.05,
currency: USDC,
network: base,
recipient: 0x1234...abcd,
description: Premium API access
}

$ xclaw02 wallet balance 0xYourAddress
{
address: 0xYourAddress,
network: base,
balance: 12.50,
token: USDC
}

$ xclaw02 pay https://api.example.com/paid --max-amount 0.10
{
status: success,
paid: 0.05,
txHash: 0xabc123...,
response: { ... }
}

在代码中使用

Node.js / TypeScript

javascript const { createSigner, x402Fetch } = require(xclaw02);

// 私钥格式:0x后跟64个十六进制字符
const signer = await createSigner(eip155:8453, process.env.XCLAW02PRIVATEKEY);
const response = await x402Fetch(https://api.example.com/paid, signer, {
maxAmount: 0.10 // 最大USDC消费额
});
const data = await response.json();

Python

python from xclaw02 import createsigner, x402requests import os

私钥格式:0x后跟64个十六进制字符

signer = createsigner(eip155:8453, os.environ[XCLAW02PRIVATE_KEY]) with x402requests(signer, maxamount=0.10) as session: response = session.get(https://api.example.com/paid) data = response.json()

销售您的服务(服务端)

想让其他代理向您支付?为您的API添加付费墙:

Express.js

javascript const express = require(express); const { x402Express } = require(xclaw02);

const app = express();

app.use(x402Express(0xYourAddress, {
/api/premium: {
amount: 0.05, // 每次请求$0.05 USDC
asset: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913,
network: eip155:8453
}
}));

app.get(/api/premium, (req, res) => {
res.json({ data: Premium content here });
});

FastAPI (Python)

python from fastapi import FastAPI from xclaw02 import x402_fastapi

app = FastAPI()

app.addmiddleware(x402fastapi(
0xYourAddress,
{
/api/premium: {
amount: 0.05,
asset: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913,
network: eip155:8453
}
}
))

@app.get(/api/premium)
async def premium_endpoint():
return {data: Premium content here}

支持的网络

网络CAIP-2 ID代币备注
Baseeip155:8453USDC主要 - 快速、便宜、推荐
Base Sepolia
eip155:84532 | USDC | 测试网 | | Ethereum | eip155:1 | USDC | 费用较高 | | Arbitrum | eip155:42161 | USDC | | | Optimism | eip155:10 | USDC | | | Polygon | eip155:137 | USDC | |

Base是默认网络。要使用其他网络,请设置XCLAW02_NETWORK环境变量。

促进者

促进者处理支付验证和链上结算。x402生态系统拥有许多独立的促进者:

名称URL备注
Primerhttps://x402.primer.systems默认
Coinbase
https://api.cdp.coinbase.com/platform/v2/x402 | |
| x402.org | https://x402.org/facilitator | 仅测试网 |
| PayAI | https://facilitator.payai.network | |
| Corbits | https://facilitator.corbits.dev | |
| Dexter | https://x402.dexter.cash | |
| Heurist | https://facilitator.heurist.xyz | |
| Kobaru | https://gateway.kobaru.io | |
| Nevermined | https://api.live.nevermined.app/api/v1/ | |
| Openfacilitator | https://pay.openfacilitator.io | |
| Solpay | https://x402.solpay.cash | |
| xEcho | https://facilitator.xechoai.xyz | |

要使用不同的促进者,请设置XCLAW02_FACILITATOR环境变量。

环境变量

变量格式描述
XCLAW02PRIVATEKEY
0x + 64个

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 xclaw02-1776369031 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 xclaw02-1776369031 技能

通过命令行安装

skillhub install xclaw02-1776369031

下载

⬇ 下载 xclaw02 v0.1.0(免费)

文件大小: 4.19 KB | 发布时间: 2026-4-17 16:10

v0.1.0 最新 2026-4-17 16:10
Initial release of xclaw02: Open payment standard for instant USDC payments using 402 Payment Required responses.

- Supports making and receiving x402 payments via CLI and code (Node.js, Python).
- Enables paying for APIs/services, handling 402 errors, creating wallets, and checking balances on Base and other EVM chains.
- Includes quick setup instructions, CLI/API usage examples, and server middleware for selling paid APIs.
- Lists supported networks, facilitators, environment variables, and common error handling.
- Emphasizes agent safety: private key security and user confirmation for payments.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部