web3-x402
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWeb3 x402
Web3 x402
An alternative authentication and billing layer for the skill. If you have an , the skill alone is sufficient. If you don't (e.g., autonomous agents), use this skill alongside — this skill handles wallet-based auth and USDC payments, while provides the API specs and parameters.
web3-toolsX-API-KEYweb3-toolsweb3-toolsweb3-tools这是技能的替代认证与结算层。如果你拥有,单独使用技能即可。如果没有(例如自主Agent),请将此技能与配合使用——本技能负责基于钱包的认证和USDC支付,而提供API规范和参数。
web3-toolsX-API-KEYweb3-toolsweb3-toolsweb3-toolsWhen to Use
使用场景
- Calling Nodit APIs without an API key (wallet + USDC only)
- SIWX authentication (SIWE for EVM, SIWS for Solana)
- Credit mode: pre-charge USDC → off-chain credit deduction per request
- PPU mode: per-request on-chain USDC settlement
- Checking credit balance or transaction history
- Understanding x402 pricing per API operation
- 无需API密钥调用Nodit API(仅使用钱包+USDC)
- SIWX认证(EVM链使用SIWE,Solana链使用SIWS)
- 预充值模式:预先充值USDC → 每次请求从链下余额中扣除额度
- 按次付费(PPU)模式:每次请求在链上完成USDC结算
- 查询余额或交易历史
- 了解各API操作的x402定价
When NOT to Use
不适用场景
- Querying blockchain data with a traditional API key → use skill instead
web3-tools - Investment advice or token value speculation
- 使用传统API密钥查询区块链数据 → 请改用技能
web3-tools - 投资建议或代币价值投机
Constraints
约束条件
- Do not give investment advice or speculate on token value
- Use only data verifiable through the Nodit x402 proxy
- Prefix responses with "According to the Nodit x402 Proxy," once
- Ask the user if required context (address, chain, mode, etc.) is missing
- 不得提供投资建议或对代币价值进行投机性分析
- 仅使用可通过Nodit x402代理验证的数据
- 回复开头需添加一次“根据Nodit x402代理信息,”
- 若缺少必要上下文(地址、链、模式等),请询问用户
Mode Selection Guide
模式选择指南
mermaid
flowchart TD
A[User request] --> B{Repeated API usage?<br/>Pre-charge preferred?}
B -->|YES| C[Credit Mode<br/>1. SIWX auth → JWT<br/>2. Charge USDC → credits<br/>3. API calls deduct credits]
B -->|NO / One-off| D[PPU Mode<br/>1. Send request without auth<br/>2. Receive 402 + payment terms<br/>3. Sign & pay per request]
C --> E{Which API?}
D --> E
E -->|Indexed data<br/>balances, NFT, tokens, stats| F[Data API]
E -->|Node calls<br/>eth_call, getBalance, etc.| G[Node API / JSON-RPC]
style C fill:#2d6a4f,color:#fff
style D fill:#7b2cbf,color:#fff
style F fill:#1d3557,color:#fff
style G fill:#6a040f,color:#fffmermaid
flowchart TD
A[用户请求] --> B{是否需要重复调用API?<br/>是否偏好预充值?}
B -->|是| C[预充值模式<br/>1. SIWX认证 → 获取JWT<br/>2. 充值USDC → 获得额度<br/>3. API调用扣除额度]
B -->|否 / 一次性调用| D[按次付费模式<br/>1. 无需认证发送请求<br/>2. 收到402响应及支付条款<br/>3. 签名并按请求支付]
C --> E{选择哪种API?}
D --> E
E -->|索引数据<br/>余额、NFT、代币、统计信息| F[数据API]
E -->|节点调用<br/>eth_call、getBalance等| G[节点API / JSON-RPC]
style C fill:#2d6a4f,color:#fff
style D fill:#7b2cbf,color:#fff
style F fill:#1d3557,color:#fff
style G fill:#6a040f,color:#fffHow to Use
使用步骤
Step 0: Confirm which wallet to use for payment
步骤0:确认用于支付的钱包
x402 requires a wallet with USDC to pay for API calls. Since this involves real funds, the user must explicitly choose which wallet to use.
- Ask the user to provide their wallet address for x402 payment (EVM or Solana).
- Look up the expected cost from or
references/pricing-data-api.md.references/pricing-node-api.md - Show the wallet address and estimated cost: "Your asset will be charged approximately $XX USDC. May I proceed?"
- Proceed to Step 1 only after the user grants permission.
x402要求钱包中持有USDC以支付API调用费用。由于涉及真实资金,用户必须明确选择使用的钱包。
- 请用户提供用于x402支付的钱包地址(EVM或Solana链)。
- 从或
references/pricing-data-api.md中查询预计费用。references/pricing-node-api.md - 向用户展示钱包地址和预估费用:“你的资产将被扣除约$XX USDC,是否继续?”
- 仅在用户确认后进入步骤1。
Step 1: Overview — Endpoints, URL patterns, 402 structure
步骤1:概述——端点、URL格式、402响应结构
Read . It contains the Base URL, endpoint table, URL patterns, 402 response structure, payment-signature format, and business rules shared across all modes.
references/how-to-use.md阅读,其中包含所有模式通用的基础URL、端点表、URL格式、402响应结构、支付签名格式和业务规则。
references/how-to-use.mdStep 2: Mode-specific implementation guide
步骤2:特定模式实现指南
Read only the document for the relevant mode:
- Credit mode → — Full flow and code covering SIWX authentication (JWT issuance), credit charging, balance checking, and API calls
references/credit-mode.md - PPU mode → — Full flow and code covering receiving a 402 without authentication → generating a payment-signature → re-requesting
references/ppu-mode.md
仅阅读对应模式的文档:
- 预充值模式 → —— 包含SIWX认证(JWT签发)、预充值、余额查询和API调用的完整流程及代码
references/credit-mode.md - 按次付费模式 → —— 包含无需认证发送请求→收到402响应→生成支付签名→重新发起请求的完整流程及代码
references/ppu-mode.md
Step 3: Check supported chains
步骤3:查看支持的链
Read to verify which chains and networks are available.
references/supported-chains.md阅读以确认可用的链和网络。
references/supported-chains.mdStep 4: Check pricing
步骤4:查看定价
Read or to find the credit cost and PPU price for the target operation.
references/pricing-data-api.mdreferences/pricing-node-api.md阅读或以获取目标操作的预充值额度成本和按次付费价格。
references/pricing-data-api.mdreferences/pricing-node-api.mdStep 5: Look up the API spec
步骤5:查阅API规范
For request parameters and response schemas, refer to the skill — the underlying APIs are the same. Use to find the operationId, then read for the full spec.
web3-toolsweb3-tools/references/quick-reference.mdweb3-tools/references/spec/{operationId}.md关于请求参数和响应结构,请参考技能——底层API是相同的。使用找到operationId,然后阅读获取完整规范。
web3-toolsweb3-tools/references/quick-reference.mdweb3-tools/references/spec/{operationId}.md