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

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

说明与用途

x402 允许 AI 代理在单个 HTTP 请求/响应周期内通过发送签名的 ERC‑20 转账证明来完成按请求计费,实现无状态、原子且可编程的微支付,无需外部支付网关。

问题

Developers building autonomous AI agents need a lightweight, standards‑based way to charge per‑request without reinventing a payment gateway.

结果

Agents can pay per request using a single HTTP round‑trip, achieving stateless, atomic, and programmable micropayments without external gateways.

工作流

  • 1. Agent sends a normal GET/POST request to the protected endpoint.
  • 2. Server responds with 402 Payment Required and an x402-payment header containing scheme, amount, nonce, and optional instructions.
  • 3. Agent parses the header, constructs a signed ERC‑20 transfer (e.g., USDC on Base) matching the amount and nonce.
  • 4. Agent retries the original request with an Authorization or x402-Payment header carrying the proof.
  • 5. Server validates the proof against the blockchain (or relayer) and returns 200 OK with the payload if valid.

证据

x402 lets a server signal that a client must attach a verifiable payment before the resource can be served.

来源

Agents often need to call paid APIs many times per second. Traditional OAuth‑2 or API‑key models either require static keys or introduce latency via redirects.

来源

The server validates the proof against the blockchain (or an off‑chain relayer) and, if valid, returns 200 OK with the requested payload.

来源

  • 记录日期: 2026-09-08T01:52:47.004Z