buy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

x402 Buy Skill

x402 付费技能

Enable AI agents to autonomously pay for HTTP resources using the x402 payment protocol.
让AI Agent能够使用x402支付协议自主为HTTP资源付费。

Overview

概述

x402 is an open payment standard that enables programmatic payments over HTTP. When an agent requests a paid resource, the server responds with HTTP 402 (Payment Required) containing payment details. The agent signs a payment authorization and retries the request.
x402是一种开放的支付标准,支持通过HTTP实现程序化支付。当Agent请求付费资源时,服务器会返回包含支付详情的HTTP 402(需要付费)响应。Agent签署支付授权后,重新发起请求。

CRITICAL: Pre-Flight Check (Do This First!)

重要提示:预检检查(务必先执行!)

ALWAYS check the endpoint's x402 version BEFORE writing any payment code.
bash
curl -i "https://example.com/api/paid-endpoint"
Look at the 402 response to determine which version and packages to use:
在编写任何支付代码之前,务必检查端点的x402版本。
bash
curl -i "https://example.com/api/paid-endpoint"
查看402响应以确定要使用的版本和包:

How to Identify Version

版本识别方法

Check Thisv1 (Legacy)v2 (Current)
x402Version
field
1
2
Network format
"base"
,
"base-sepolia"
"eip155:8453"
,
"eip155:84532"
(CAIP-2)
Requirements locationBody only
PAYMENT-REQUIRED
header
Payment header to send
X-PAYMENT
PAYMENT-SIGNATURE
Response header
X-PAYMENT-RESPONSE
PAYMENT-RESPONSE
Example v1 response:
json
{"x402Version":1,"accepts":[{"network":"base","maxAmountRequired":"2000",...}]}
Example v2 response:
PAYMENT-REQUIRED: <base64-encoded>
{"x402Version":2,"accepts":[{"network":"eip155:8453","maxAmountRequired":"2000",...}]}
检查项v1(旧版)v2(当前版)
x402Version
字段
1
2
网络格式
"base"
,
"base-sepolia"
"eip155:8453"
,
"eip155:84532"
(CAIP-2)
要求位置仅在响应体中
PAYMENT-REQUIRED
请求头
需发送的支付请求头
X-PAYMENT
PAYMENT-SIGNATURE
响应头
X-PAYMENT-RESPONSE
PAYMENT-RESPONSE
v1响应示例:
json
{"x402Version":1,"accepts":[{"network":"base","maxAmountRequired":"2000",...}]}
v2响应示例:
PAYMENT-REQUIRED: <base64-encoded>
{"x402Version":2,"accepts":[{"network":"eip155:8453","maxAmountRequired":"2000",...}]}

Quick Start

快速开始

1. Setup Wallet

1. 设置钱包

Non-interactive CLI commands (for AI agents):
bash
undefined
非交互式CLI命令(适用于AI Agent):
bash
undefined

EVM wallet (Base, Ethereum, Avalanche) - pipes "1" to select EOA

EVM钱包(Base、Ethereum、Avalanche)- 输入"1"选择EOA

echo "1" | npx add-wallet evm
echo "1" | npx add-wallet evm

Solana wallet

Solana钱包

npx add-wallet sol
npx add-wallet sol

Top up with testnet USDC

充值测试网USDC

npx add-wallet topup testnet

This creates a `.env` file with `WALLET_ADDRESS` and `WALLET_PRIVATE_KEY`.
npx add-wallet topup testnet

此命令会创建一个包含`WALLET_ADDRESS`和`WALLET_PRIVATE_KEY`的`.env`文件。

2. Install Packages (Based on Version)

2. 安装对应版本的包

For v1 endpoints:
bash
npm install x402-fetch viem
For v2 endpoints:
bash
npm install @x402/fetch @x402/evm viem
针对v1端点:
bash
npm install x402-fetch viem
针对v2端点:
bash
npm install @x402/fetch @x402/evm viem

Optional for Solana: npm install @x402/svm @solana/kit @scure/base

Solana可选依赖:npm install @x402/svm @solana/kit @scure/base

undefined
undefined

3. Make Paid Requests

3. 发起付费请求

For v1 Endpoints (Legacy)

针对v1端点(旧版)

typescript
import { wrapFetchWithPayment, createSigner, decodeXPaymentResponse } from "x402-fetch";

const privateKey = process.env.WALLET_PRIVATE_KEY as `0x${string}`;

// Use network string from 402 response: "base", "base-sepolia", "solana", etc.
const signer = await createSigner("base", privateKey);
const fetchWithPayment = wrapFetchWithPayment(fetch, signer);

const response = await fetchWithPayment("https://api.example.com/paid", { method: "GET" });
const data = await response.json();

// Check payment receipt
const paymentResponse = response.headers.get("x-payment-response");
if (paymentResponse) {
  const receipt = decodeXPaymentResponse(paymentResponse);
  console.log("Payment settled:", receipt);
}
typescript
import { wrapFetchWithPayment, createSigner, decodeXPaymentResponse } from "x402-fetch";

const privateKey = process.env.WALLET_PRIVATE_KEY as `0x${string}`;

// 使用402响应中的网络字符串:"base", "base-sepolia", "solana"等
const signer = await createSigner("base", privateKey);
const fetchWithPayment = wrapFetchWithPayment(fetch, signer);

const response = await fetchWithPayment("https://api.example.com/paid", { method: "GET" });
const data = await response.json();

// 检查支付凭证
const paymentResponse = response.headers.get("x-payment-response");
if (paymentResponse) {
  const receipt = decodeXPaymentResponse(paymentResponse);
  console.log("Payment settled:", receipt);
}

For v2 Endpoints (Current)

针对v2端点(当前版)

typescript
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
registerExactEvmScheme(client, { signer });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment("https://api.example.com/paid", { method: "GET" });

// Check payment receipt
const paymentResponse = response.headers.get("PAYMENT-RESPONSE");
typescript
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
registerExactEvmScheme(client, { signer });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);
const response = await fetchWithPayment("https://api.example.com/paid", { method: "GET" });

// 检查支付凭证
const paymentResponse = response.headers.get("PAYMENT-RESPONSE");

Package Reference

包参考

Purposev1 (Legacy)v2 (Current)
Fetch wrapper
x402-fetch
@x402/fetch
Axios wrapper
x402-axios
@x402/axios
Core types
x402
@x402/core
EVM supportBuilt into x402-fetch
@x402/evm
Solana supportBuilt into x402-fetch
@x402/svm
用途v1(旧版)v2(当前版)
Fetch包装器
x402-fetch
@x402/fetch
Axios包装器
x402-axios
@x402/axios
核心类型
x402
@x402/core
EVM支持内置在x402-fetch中
@x402/evm
Solana支持内置在x402-fetch中
@x402/svm

Network Identifiers

网络标识符

Networkv1 IDv2 CAIP-2 IDEnvironment
Base Mainnet
base
eip155:8453
Production
Base Sepolia
base-sepolia
eip155:84532
Testnet
Avalanche C-Chain
avalanche
eip155:43114
Production
Avalanche Fuji
avalanche-fuji
eip155:43113
Testnet
Solana Mainnet
solana
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
Production
Solana Devnet
solana-devnet
solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
Testnet
网络v1 IDv2 CAIP-2 ID环境
Base主网
base
eip155:8453
生产环境
Base Sepolia测试网
base-sepolia
eip155:84532
测试环境
Avalanche C-Chain
avalanche
eip155:43114
生产环境
Avalanche Fuji测试网
avalanche-fuji
eip155:43113
测试环境
Solana主网
solana
solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp
生产环境
Solana Devnet测试网
solana-devnet
solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
测试环境

USDC Token Addresses

USDC代币地址

NetworkUSDC Address
Base Mainnet
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Base Sepolia
0x036CbD53842c5426634e7929541eC2318f3dCF7e
Avalanche
0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
Solana Mainnet
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
网络USDC地址
Base主网
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Base Sepolia测试网
0x036CbD53842c5426634e7929541eC2318f3dCF7e
Avalanche
0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
Solana主网
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

Complete Working Examples

完整可用示例

Example 1: Calling a v1 Endpoint

示例1:调用v1端点

typescript
// call-v1-endpoint.ts
import { wrapFetchWithPayment, createSigner, decodeXPaymentResponse } from "x402-fetch";

const privateKey = "0x..." as `0x${string}`; // Your private key
const walletAddress = "0x..."; // Your wallet address

async function main() {
  // Step 1: Check what version the endpoint uses
  const checkResponse = await fetch("https://example.com/api/data");
  if (checkResponse.status === 402) {
    const body = await checkResponse.json();
    console.log("x402 Version:", body.x402Version);
    console.log("Network:", body.accepts[0].network);
    console.log("Price:", body.accepts[0].maxAmountRequired, "atomic units");
  }

  // Step 2: Create signer with v1 network string
  const signer = await createSigner("base", privateKey); // Use network from response

  // Step 3: Wrap fetch and make paid request
  const fetchWithPayment = wrapFetchWithPayment(fetch, signer);
  const response = await fetchWithPayment("https://example.com/api/data");
  const data = await response.json();
  console.log("Response:", data);

  // Step 4: Check payment receipt
  const receipt = response.headers.get("x-payment-response");
  if (receipt) {
    console.log("Payment settled:", decodeXPaymentResponse(receipt));
  }
}

main().catch(console.error);
typescript
// call-v1-endpoint.ts
import { wrapFetchWithPayment, createSigner, decodeXPaymentResponse } from "x402-fetch";

const privateKey = "0x..." as `0x${string}`; // 你的私钥
const walletAddress = "0x..."; // 你的钱包地址

async function main() {
  // 步骤1:检查端点使用的版本
  const checkResponse = await fetch("https://example.com/api/data");
  if (checkResponse.status === 402) {
    const body = await checkResponse.json();
    console.log("x402 Version:", body.x402Version);
    console.log("Network:", body.accepts[0].network);
    console.log("Price:", body.accepts[0].maxAmountRequired, "atomic units");
  }

  // 步骤2:使用v1网络字符串创建签名器
  const signer = await createSigner("base", privateKey); // 使用响应中的网络

  // 步骤3:包装fetch并发起付费请求
  const fetchWithPayment = wrapFetchWithPayment(fetch, signer);
  const response = await fetchWithPayment("https://example.com/api/data");
  const data = await response.json();
  console.log("Response:", data);

  // 步骤4:检查支付凭证
  const receipt = response.headers.get("x-payment-response");
  if (receipt) {
    console.log("Payment settled:", decodeXPaymentResponse(receipt));
  }
}

main().catch(console.error);

Example 2: Calling a v2 Endpoint

示例2:调用v2端点

typescript
// call-v2-endpoint.ts
import { wrapFetchWithPayment, x402Client, x402HTTPClient } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const privateKey = "0x..." as `0x${string}`;

async function main() {
  // Step 1: Check what version the endpoint uses
  const checkResponse = await fetch("https://example.com/api/data");
  if (checkResponse.status === 402) {
    const hasV2Header = checkResponse.headers.get("PAYMENT-REQUIRED");
    console.log("Is v2:", !!hasV2Header);
  }

  // Step 2: Setup v2 client
  const signer = privateKeyToAccount(privateKey);
  const client = new x402Client();
  registerExactEvmScheme(client, { signer });

  // Step 3: Make paid request
  const fetchWithPayment = wrapFetchWithPayment(fetch, client);
  const response = await fetchWithPayment("https://example.com/api/data");
  const data = await response.json();
  console.log("Response:", data);

  // Step 4: Check payment receipt
  const receipt = response.headers.get("PAYMENT-RESPONSE");
  if (receipt) {
    console.log("Payment settled");
  }
}

main().catch(console.error);
typescript
// call-v2-endpoint.ts
import { wrapFetchWithPayment, x402Client, x402HTTPClient } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const privateKey = "0x..." as `0x${string}`;

async function main() {
  // 步骤1:检查端点使用的版本
  const checkResponse = await fetch("https://example.com/api/data");
  if (checkResponse.status === 402) {
    const hasV2Header = checkResponse.headers.get("PAYMENT-REQUIRED");
    console.log("Is v2:", !!hasV2Header);
  }

  // 步骤2:设置v2客户端
  const signer = privateKeyToAccount(privateKey);
  const client = new x402Client();
  registerExactEvmScheme(client, { signer });

  // 步骤3:发起付费请求
  const fetchWithPayment = wrapFetchWithPayment(fetch, client);
  const response = await fetchWithPayment("https://example.com/api/data");
  const data = await response.json();
  console.log("Response:", data);

  // 步骤4:检查支付凭证
  const receipt = response.headers.get("PAYMENT-RESPONSE");
  if (receipt) {
    console.log("Payment settled");
  }
}

main().catch(console.error);

Service Discovery (Bazaar)

服务发现(Bazaar)

Find x402-enabled services without knowing URLs in advance.
bash
undefined
无需提前知道URL即可找到支持x402的服务。
bash
undefined

Quick discovery via curl

通过curl快速发现

curl -s "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources?type=http&limit=50" | jq '.items[] | {url: .resource, price: .accepts[0].maxAmountRequired, version: .x402Version}'
undefined
curl -s "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources?type=http&limit=50" | jq '.items[] | {url: .resource, price: .accepts[0].maxAmountRequired, version: .x402Version}'
undefined

Programmatic Discovery

程序化发现

typescript
import { HTTPFacilitatorClient } from "@x402/core/http";
import { withBazaar } from "@x402/extensions";

const facilitatorClient = new HTTPFacilitatorClient({
  url: "https://api.cdp.coinbase.com/platform/v2/x402"
});
const client = withBazaar(facilitatorClient);

const response = await client.extensions.discovery.listResources({ type: "http" });

// Filter by price (under $0.01 = 10000 atomic units)
const affordable = response.items.filter(item =>
  Number(item.accepts[0].maxAmountRequired) < 10000
);
typescript
import { HTTPFacilitatorClient } from "@x402/core/http";
import { withBazaar } from "@x402/extensions";

const facilitatorClient = new HTTPFacilitatorClient({
  url: "https://api.cdp.coinbase.com/platform/v2/x402"
});
const client = withBazaar(facilitatorClient);

const response = await client.extensions.discovery.listResources({ type: "http" });

// 按价格筛选(低于0.01美元 = 10000原子单位)
const affordable = response.items.filter(item =>
  Number(item.accepts[0].maxAmountRequired) < 10000
);

Payment Amounts

支付金额对照表

Amount (atomic)USDC Value
1000
$0.001 (0.1 cents)
2000
$0.002
10000
$0.01 (1 cent)
100000
$0.10 (10 cents)
1000000
$1.00
原子单位数量USDC价值
1000
$0.001(0.1美分)
2000
$0.002
10000
$0.01(1美分)
100000
$0.10(10美分)
1000000
$1.00

Extracting Endpoint Requirements (Method, Body, Schema)

提取端点要求(方法、请求体、Schema)

Many x402 endpoints include detailed input/output schemas in their 402 response. This tells you:
  • What HTTP method to use (GET, POST, etc.)
  • What body format (JSON, form-data)
  • Required and optional fields
许多x402端点会在402响应中包含详细的输入/输出Schema,这些信息会告诉你:
  • 要使用的HTTP方法(GET、POST等)
  • 请求体格式(JSON、form-data)
  • 必填和可选字段

Step 1: Get the 402 Response

步骤1:获取402响应

bash
undefined
bash
undefined

Try GET first

先尝试GET方法

If you get 405 Method Not Allowed, try POST

如果返回405 Method Not Allowed,尝试POST方法

curl -i -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json"
undefined
curl -i -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json"
undefined

Step 2: Decode and Inspect the Payment Header

步骤2:解码并检查支付请求头

For v2 endpoints, decode the
PAYMENT-REQUIRED
header:
bash
undefined
对于v2端点,解码
PAYMENT-REQUIRED
请求头:
bash
undefined

Extract and decode the header (save full header value to a file or variable)

提取并解码请求头(将完整的请求头值保存到文件或变量中)

echo "<base64-payment-required-value>" | base64 -d | jq '.'
undefined
echo "<base64-payment-required-value>" | base64 -d | jq '.'
undefined

Step 3: Find the Input Schema

步骤3:查找输入Schema

Look for
extensions.bazaar.schema.properties.input
in the decoded response:
json
{
  "x402Version": 2,
  "accepts": [...],
  "extensions": {
    "bazaar": {
      "info": {
        "input": {
          "type": "http",
          "method": "POST",        // <-- HTTP method
          "bodyType": "json",      // <-- Body format
          "body": {}
        }
      },
      "schema": {
        "properties": {
          "input": {
            "properties": {
              "body": {
                "properties": {
                  "urls": { "type": "array", "items": { "type": "string" } },  // Required field
                  "text": { "type": "boolean" }  // Optional field
                },
                "required": ["urls"]  // <-- Required fields listed here
              }
            }
          }
        }
      }
    }
  }
}
在解码后的响应中查找
extensions.bazaar.schema.properties.input
json
{
  "x402Version": 2,
  "accepts": [...],
  "extensions": {
    "bazaar": {
      "info": {
        "input": {
          "type": "http",
          "method": "POST",        // <-- HTTP方法
          "bodyType": "json",      // <-- 请求体格式
          "body": {}
        }
      },
      "schema": {
        "properties": {
          "input": {
            "properties": {
              "body": {
                "properties": {
                  "urls": { "type": "array", "items": { "type": "string" } },  // 必填字段
                  "text": { "type": "boolean" }  // 可选字段
                },
                "required": ["urls"]  // <-- 必填字段列表
              }
            }
          }
        }
      }
    }
  }
}

Step 4: Build Your Request

步骤4:构建请求

Based on the schema above:
typescript
const response = await fetchWithPayment("https://example.com/api/endpoint", {
  method: "POST",  // From info.input.method
  headers: { "Content-Type": "application/json" },  // From info.input.bodyType
  body: JSON.stringify({
    urls: ["https://example.com"],  // Required field
    text: true  // Optional field
  })
});
基于上面的Schema:
typescript
const response = await fetchWithPayment("https://example.com/api/endpoint", {
  method: "POST",  // 来自info.input.method
  headers: { "Content-Type": "application/json" },  // 来自info.input.bodyType
  body: JSON.stringify({
    urls: ["https://example.com"],  // 必填字段
    text: true  // 可选字段
  })
});

Quick Schema Extraction (One-liner)

快速提取Schema(单行命令)

bash
curl -s -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json" | \
  jq -r 'if .accepts then . else empty end' 2>/dev/null || \
  echo "Check PAYMENT-REQUIRED header for v2"
For v2 with header:
bash
curl -si -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json" | \
  grep -i "payment-required:" | cut -d' ' -f2 | base64 -d | \
  jq '{method: .extensions.bazaar.info.input.method, bodyType: .extensions.bazaar.info.input.bodyType, required: .extensions.bazaar.schema.properties.input.properties.body.required}'
bash
curl -s -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json" | \
  jq -r 'if .accepts then . else empty end' 2>/dev/null || \
  echo "Check PAYMENT-REQUIRED header for v2"
针对带请求头的v2端点:
bash
curl -si -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json" | \
  grep -i "payment-required:" | cut -d' ' -f2 | base64 -d | \
  jq '{method: .extensions.bazaar.info.input.method, bodyType: .extensions.bazaar.info.input.bodyType, required: .extensions.bazaar.schema.properties.input.properties.body.required}'

Common Patterns

常见模式

If you see...Then use...
"method": "GET"
fetch(url)
"method": "POST"
+
"bodyType": "json"
fetch(url, { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({...}) })
"method": "POST"
+
"bodyType": "form-data"
fetch(url, { method: "POST", body: formData })
No
extensions.bazaar
Try GET first, then POST if 405
如果看到...则使用...
"method": "GET"
fetch(url)
"method": "POST"
+
"bodyType": "json"
fetch(url, { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({...}) })
"method": "POST"
+
"bodyType": "form-data"
fetch(url, { method: "POST", body: formData })
extensions.bazaar
先尝试GET,若返回405再尝试POST

Setup Checklist

设置检查清单

  1. Create wallet - Run
    echo "1" | npx add-wallet evm
    (non-interactive)
  2. Note the address - Check
    .env
    for
    WALLET_ADDRESS
  3. Fund wallet - Send USDC on Base mainnet (or
    npx add-wallet topup testnet
    )
  4. Check endpoint -
    curl -i <url>
    to see:
    • x402 version (v1 or v2)
    • Price (amount field)
    • Network (mainnet or testnet)
    • If 405, try
      curl -i -X POST <url>
  5. Extract schema - Decode
    PAYMENT-REQUIRED
    header to find method, body format, required fields
  6. Install correct packages - v1:
    x402-fetch
    , v2:
    @x402/fetch @x402/evm
  7. Use correct code pattern - v1:
    createSigner()
    , v2:
    registerExactEvmScheme()
  8. Build request - Use method/body from schema, SDK handles 402 → payment → retry
  1. 创建钱包 - 运行
    echo "1" | npx add-wallet evm
    (非交互式)
  2. 记录钱包地址 - 在
    .env
    文件中查看
    WALLET_ADDRESS
  3. 为钱包充值 - 在Base主网发送USDC(或运行
    npx add-wallet topup testnet
    充值测试网)
  4. 检查端点 - 运行
    curl -i <url>
    查看:
    • x402版本(v1或v2)
    • 价格(amount字段)
    • 网络(主网或测试网)
    • 若返回405,尝试
      curl -i -X POST <url>
  5. 提取Schema - 解码
    PAYMENT-REQUIRED
    请求头,找到方法、请求体格式和必填字段
  6. 安装正确的包 - v1使用
    x402-fetch
    ,v2使用
    @x402/fetch @x402/evm
  7. 使用正确的代码模式 - v1用
    createSigner()
    ,v2用
    registerExactEvmScheme()
  8. 构建请求 - 使用Schema中的方法和请求体,SDK会自动处理402→支付→重试流程

Troubleshooting

故障排除

HTTP 405 Method Not Allowed

HTTP 405 Method Not Allowed

The endpoint requires a different HTTP method. Try POST instead of GET:
bash
curl -i -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json"
端点需要使用不同的HTTP方法。尝试用POST替代GET:
bash
curl -i -X POST "https://example.com/api/endpoint" -H "Content-Type: application/json"

"EIP-712 domain parameters required" Error

"EIP-712 domain parameters required" 错误

You're using v2 packages (
@x402/fetch
) on a v1 endpoint. Check the 402 response - if
x402Version: 1
, use
x402-fetch
instead.
你正在将v2包(
@x402/fetch
)用于v1端点。检查402响应,如果
x402Version: 1
,请改用
x402-fetch

"No scheme registered" Error

"No scheme registered" 错误

The network in the 402 response isn't registered. For v2, make sure you called
registerExactEvmScheme(client, { signer })
.
402响应中的网络未注册。对于v2,确保你已调用
registerExactEvmScheme(client, { signer })

Payment succeeds but response is empty or error

支付成功但响应为空或报错

You might be missing required body fields. Decode the
PAYMENT-REQUIRED
header and check
extensions.bazaar.schema
for required fields.
你可能遗漏了必填的请求体字段。解码
PAYMENT-REQUIRED
请求头,检查
extensions.bazaar.schema
中的必填字段。

Payment not going through

支付无法完成

  1. Check wallet has sufficient USDC balance on the correct network
  2. Verify you're using the right network (mainnet vs testnet)
  3. Check the
    network
    field in the 402 response matches your setup
  1. 检查钱包在对应网络上是否有足够的USDC余额
  2. 确认你使用的网络正确(主网vs测试网)
  3. 检查402响应中的
    network
    字段是否与你的设置匹配

Protocol References

协议参考

For detailed protocol schemas, see:
  • references/wallet-setup.md
  • references/v1-protocol.md
  • references/v2-protocol.md
如需详细的协议Schema,请查看:
  • references/wallet-setup.md
  • references/v1-protocol.md
  • references/v2-protocol.md