Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

x402 Explained: HTTP‑Native Micropayments for AI Agents (With Real Code)

说明与用途

自主代理可以使用 x402 协议自动支付 API 调用,将支付嵌入 HTTP 流量中。

问题

Autonomous agents need to consume paid services without human intervention, but traditional billing methods add coupling and require pre‑provisioned balances.

结果

Agents can autonomously pay for API calls using on‑chain micropayments, reducing coupling and manual billing.

工作流

  • 1. Agent sends normal GET/POST to protected endpoint.
  • 2. Server responds with 402 and headers (X-Amount, X-Currency, X-Chain-ID, X-Payment-Request, X-Pay-To).
  • 3. Agent builds and sends on‑chain transaction per X-Payment-Request.
  • 4. After mining, agent extracts txHash and retries original request with X-Payment-Proof header or body field.
  • 5. Server verifies txHash, amount, recipient, and nonce; if valid, processes request and returns 200.

证据

The x402 specification repurposes the HTTP 402 Payment Required status code to turn every request into a self‑contained payment negotiation.

来源

Server verifies that the txHash corresponds to a transaction on the correct chain and that the transaction sent the expected amount to the payee.

来源

  • 记录日期: 2026-09-15T04:16:41.920Z