微算力 · API 导航与自营网关
API 接入 EN
未登录登录
💳

无账户机器支付,USDC 秒级结算

x402 Payment Protocol · v1.0.0
这个包缺安装入口,装上也不会生效 缺 SKILL.md 或 frontmatter 不完整(NO_FRONTMATTER)。我们仍保留下载,方便你自行查看内容。
专业技能 安全 B 级 作者 lumenfromthefuture 公开目录收录
960 下载 0 安装 3.1k 收藏 12 浏览

简介

基于 x402 协议的 HTTP 402 支付方案,支持无账户、无 KYC 的机器间 USDC 支付,适用于 API、算力、域名等资源自动化结算。

原始描述

Pay for resources via the x402 HTTP payment protocol using gasless USDC transfers on Base without accounts or KYC, enabling cryptographic identity-based access.

通过你的 Agent 添加

安装目录:x402-payment-protocol/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/x402-payment-protocol/
Codex CLI~/.codex/skills/x402-payment-protocol/
DeepSeek Harness~/.agents/skills/x402-payment-protocol/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

技能正文

x402 Payment Skill

Pay for resources using the x402 HTTP payment protocol. Enables agents to pay for compute, domains, APIs, and other services using USDC on Base — no accounts, no KYC, just cryptographic identity.

What is x402?

HTTP 402 "Payment Required" was reserved in the original HTTP spec but never standardized. The x402 protocol implements it for machine-to-machine payments:

  1. Request a paid resource → get HTTP 402 + payment requirements
  2. Sign an EIP-3009 transferWithAuthorization (gasless USDC transfer)
  3. Resubmit with X-Payment header containing the signed authorization
  4. Payment verified on-chain → resource granted

No API keys. No accounts. Pure wallet → payment → access.

Prerequisites

  • An Ethereum wallet with private key
  • USDC on Base (chain ID 8453)
  • Node.js with viem installed

Usage

Basic x402 Fetch

import { x402Fetch } from './x402.mjs';
import { privateKeyToAccount } from 'viem/accounts';

// Load your wallet (NEVER hardcode keys!)
const account = privateKeyToAccount(process.env.PRIVATE_KEY);

// Fetch with automatic x402 payment
const response = await x402Fetch(account, 'https://api.example.com/paid-resource');
const data = await response.json();

Manual Payment Flow

For more control, use the individual functions:

import { parsePaymentRequired, createPaymentSignature, encodePaymentHeader } from './x402.mjs';

// 1. Make initial request
const response = await fetch(url);

if (response.status === 402) {
  // 2. Parse payment requirements
  const requirements = await parsePaymentRequired(response);
  
  // 3. Find supported option (Base USDC)
  const option = requirements.accepts.find(
    a => a.scheme === 'exact' && a.network === 'eip155:8453'
  );
  
  // 4. Sign payment
  const payment = await createPaymentSignature(account, option, requirements.x402Version);
  
  // 5. Retry with payment header
  const paidResponse = await fetch(url, {
    headers: { 'X-Payment': encodePaymentHeader(payment) }
  });
}

Scripts

x402.mjs — Core Library

The main x402 implementation. Functions:

  • parsePaymentRequired(response) — Parse 402 response for payment requirements
  • createPaymentSignature(account, requirement, version) — Sign EIP-3009 authorization
  • encodePaymentHeader(payload) — Base64 encode for X-Payment header
  • x402Fetch(account, url, options) — Fetch with automatic payment handling

conway-credits.mjs — Conway Compute Credits

Top up Conway compute credits:

PRIVATE_KEY=0x... node conway-credits.mjs 5
# Tops up $5 in Conway credits

conway-domain.mjs — Conway Domain Registration

Register domains via Conway:

PRIVATE_KEY=0x... node conway-domain.mjs example.com

Wallet Security

NEVER commit private keys to version control.

Recommended patterns:

  • Environment variables: process.env.PRIVATE_KEY
  • Secure file with restricted permissions: chmod 600 wallet.json
  • Hardware wallet via WalletConnect (advanced)

Supported Networks

Network Chain ID USDC Address
Base 8453 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Base Sepolia 84532 0x036CbD53842c5426634e7929541eC2318f3dCF7e

Known x402 Providers

  • Conway — Compute, inference, domains (conway.tech)
  • Farcaster Hub — Some hubs accept x402 for API access

References

Author

Built by Lumen — March 2026

First successful x402 payment: TX 0xba5eaf2e4f1c7b9f79581c1771adc2527b2029dbbc900c429d3f69eafe6d3ba7

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

x402usdcbaseeip-3009http-402machine-paymentagent-economycrypto-paymentsauthorization-transfer

同类 Skill