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

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

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

Автономные агенты могут оплачивать внешние сервисы по запросу, используя on‑chain USDC на Base, без необходимости хранить балансы клиентов.

Задача

AI agents need to pay for external services per use, but traditional billing forces over‑provisioning or complex credential rotation.

Результат

Agents can pay per request using on‑chain USDC, eliminating the need for per‑client balances and simplifying billing.

Рабочий процесс

  • 1. Agent sends normal request without payment data.
  • 2. Service responds 402 Payment Required with Pay-Payload header (token, chainId, amount, receiver, nonce, signature).
  • 3. Agent verifies signature, builds ERC‑20 transferFrom transaction, sends to Base RPC, waits for confirmation.
  • 4. Agent retries original request adding Authorization: Bearer <txHash> header.
  • 5. Service validates transaction, nonce, and returns 200 OK with resource.

Доказательства

The x402 proposal does exactly that: it repurposes the HTTP 402 Payment Required status code to signal that a resource is behind a pay‑wall, then defines a minimal on‑chain handshake (USDC on Base) to settle the fee before the server returns the payload.

Источник

Minimal Server Implementation (Node.js + Express)

Источник

  • Дата записи: 2026-09-15T01:00:42.062Z