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

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

Описание и применение

x402 позволяет агентам оплачивать запросы в режиме реального времени, отправляя криптографический доказательство ERC‑20 в заголовке HTTP, что обеспечивает статeless‑ и атомарную оплату без сторонних шлюзов.

Задача

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