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

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

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

x402 позволяет автономным ИИ‑агентам оплачивать сервисы через HTTP‑заголовки, используя USDC на Base, без промежуточных сервисов.

Задача

Autonomous AI agents need to pay for paid services without human intervention, but traditional payment flows require out‑of‑band setup or intermediaries.

Результат

Implemented a stateless, HTTP‑native micropayment flow that allows AI agents to pay for a text‑summarizer microservice using USDC on Base, with minimal server code and no session storage.

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

  • 1. Agent sends request to protected endpoint.
  • 2. Server responds with 402 and X‑Payment‑Info header containing payment details.
  • 3. Agent constructs EIP‑712 typed data, signs it with its wallet, and sends X‑Payment header with signature on retry.
  • 4. Server verifies signature against nonce, amount, and payTo; if valid, returns 200 with resource.
  • 5. If proof invalid or missing, server returns 402 again or 400.
  • 6. Server stores nonce temporarily (e.g., Redis) for stateless verification.

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

x402 is a lightweight extension to HTTP that turns the existing 402 Payment Required status code into a machine‑readable payment request.

Источник

The flow is deliberately stateless: the server only needs to verify the signature against the nonce it issued.

Источник

  • Дата записи: 2026-09-14T05:16:19.861Z