闲社服务运行正常AI智能体自动化平台
n

x402支付协议

技能标识:neckr0ik-x402-payments

x402 payment protocol for AI agents. Enables autonomous micropayments using HTTP 402 status codes and stablecoins. Use when you need to pay for API access, accept payments for your services, or interact with x402-enabled endpoints.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

x402支付协议

面向AI代理的x402支付系统

基于HTTP 402和稳定币的AI代理自主支付协议。

什么是x402?

x402是一种面向互联网原生支付的开放标准。它使AI代理能够使用稳定币自动支付API调用费用,无需账户或人工干预。

工作原理:

  1. 1. 代理请求API端点
  2. 服务器响应HTTP 402状态码及支付详情
  3. 代理签署支付授权
  4. 支付在区块链上结算
  5. 请求自动完成

主要优势:

  • - 无需账户或API密钥
  • 即时结算
  • 按请求微支付
  • 区块链无关(EVM + Solana)
  • 完美适用于自主代理

快速开始

检查端点是否支持x402

bash
neckr0ik-x402-payments check https://api.example.com/premium

支付API访问费用

bash
neckr0ik-x402-payments pay https://api.example.com/premium --amount 0.01

接受支付(针对您的API)

bash
neckr0ik-x402-payments serve --port 8080 --price 0.01

支付流程

代理 x402协调器 API服务器
| | |
|-- GET /premium ------>|----------------------->|
| | |
|<-- HTTP 402 -----------|------------------------|
| (需要支付) | |
| {金额, 地址, | |
| 链, 协调器} | |
| | |
|-- 签署支付 ---------->| |
| | |
| |-- 提交到链 ---------->|
| | |
| |<-- 确认 ---------------|
| | |
|-- GET /premium --------|----------------------->|
| 支付签名 | |
| | |
|<-- 200 OK -------------|------------------------|
| (数据) | |

支持的链

  • - 以太坊(主网、L2)
  • Polygon
  • Base
  • Arbitrum
  • Optimism
  • Solana

支持的稳定币

  • - USDC
  • USDT
  • DAI

命令

check

检查端点是否支持x402支付。

bash
neckr0ik-x402-payments check

选项:
--timeout <毫秒> 请求超时时间(默认:10000)

pay

支付API访问费用并接收数据。

bash
neckr0ik-x402-payments pay [选项]

选项:
--amount <金额> 最大支付金额(美元)
--chain <链> 首选链(默认:base)
--token <代币> 稳定币代币(默认:usdc)
--wallet <地址> 用于支付的钱包
--dry-run 显示支付详情但不实际支付

serve

启动支持x402的API服务器。

bash
neckr0ik-x402-payments serve [选项]

选项:
--port <端口> 服务器端口(默认:8080)
--price <金额> 每次请求价格(美元)
--chain <链> 接受支付的链(默认:base)
--token <代币> 接受的稳定币(默认:usdc)
--wallet <地址> 收款钱包地址

balance

查看支付钱包余额。

bash
neckr0ik-x402-payments balance [选项]

选项:
--chain <链> 要检查的链(默认:全部)

history

查看支付历史。

bash
neckr0ik-x402-payments history [选项]

选项:
--limit <数量> 交易数量(默认:10)
--chain <链> 按链筛选

配置

设置支付钱包:

bash

设置钱包私钥(安全存储)


neckr0ik-x402-payments config set wallet.private_key <密钥>

或使用环境变量

export X402PRIVATEKEY=<密钥>

设置收款地址

neckr0ik-x402-payments config set wallet.address <地址>

使用场景

作为代理(支付API访问费用)

python

之前:需要API密钥、账户、订阅


response = requests.get(https://api.example.com/data,
headers={Authorization: Bearer YOURAPIKEY})

之后:自主支付,无需账户

response = x402.get(https://api.example.com/data)

作为提供方(接受支付)

python
from x402 import PaymentMiddleware

app = Flask(name)
app.wsgiapp = PaymentMiddleware(app.wsgiapp, price=0.01)

@app.route(/premium-data)
def premium_data():
return {data: only accessible after payment}

对/premium-data的请求自动要求支付

安全性

  • - 私钥永不离开您的机器
  • 支付在本地签署
  • 通过协调器广播交易
  • 所有结算在链上验证
  • 支付收据存储以供审计

参见

  • - references/x402-spec.md — 完整协议规范
  • references/facilitators.md — 已知协调器列表
  • scripts/x402.py — 支付实现

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 neckr0ik-x402-payments-1776198611 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 neckr0ik-x402-payments-1776198611 技能

通过命令行安装

skillhub install neckr0ik-x402-payments-1776198611

下载

⬇ 下载 neckr0ik-x402-payments v1.0.0(免费)

文件大小: 6.77 KB | 发布时间: 2026-4-15 12:52

v1.0.0 最新 2026-4-15 12:52
Initial release of the x402 payment protocol skill for AI agents.

- Enables autonomous micropayments for API access using HTTP 402 status codes and stablecoins.
- Supports paying for, accepting, and verifying x402-enabled endpoints.
- Compatible with major blockchains (Ethereum, Polygon, Base, Arbitrum, Optimism, Solana) and stablecoins (USDC, USDT, DAI).
- Provides CLI commands for checking endpoints, making payments, running a payment-enabled API server, checking balances, and viewing payment history.
- Emphasizes secure local key management and on-chain payment settlement.
- Includes usage examples for both agents (consumers) and service providers.
返回顶部