ChangeGamer

← All resources

Agent Wallets: Paying Per Run with x402

Guide · updated 2026-07-02 · Markdown variant

Buyer-side guide to giving an AI agent a wallet: how the x402 payment loop works, the client libraries that automate it, spend controls, and what 20,000+ Apify Actors on x402 mean for agent tool budgets.


In June 2026, Apify — in partnership with Coinbase — put 20,000+ Actors on x402, roughly 10x the ~2,000 payable endpoints the ecosystem offered before. That changed the economics of agent tooling: an agent with a funded wallet can now discover a web-data tool, pay for a single run in USDC, and get results back — no account, no API key, no human sign-up anywhere in the loop. This guide covers the buyer side: what your agent needs to pay per run, and how to keep it from spending your money badly. For the protocol comparison and the seller side, see agentic payment protocols.

What the agent actually does

The x402 loop is four steps, and libraries automate all of them:

  1. The agent calls a paid endpoint normally (GET /priced-thing).
  2. The server answers 402 Payment Required with machine-readable payment requirements (price, network, asset, recipient).
  3. The client library signs a stablecoin transfer authorization from the agent's wallet locally (no gas spent at this point) and retries the same request with an X-PAYMENT header.
  4. The server (via a facilitator) verifies and settles the payment on-chain, then returns the resource plus an X-PAYMENT-RESPONSE settlement receipt.

From the agent's point of view, a paid API call is just an HTTP call that costs money. No OAuth dance, no key vault entry, no invoice.

What you need

Piece What it is Notes
Wallet An EVM account the agent can sign with USDC on Base is the ecosystem default; fund it with small amounts only
Client library Wraps HTTP and handles the 402→sign→retry loop JS/TS: @x402/fetch or @x402/axios + @x402/evm; Python: x402[httpx] (async) or x402[requests] (sync)
Budget policy Your own spend controls The upto scheme lets you authorize a maximum and be charged actual usage

The signing key IS the budget: anyone (any process) holding it can spend the wallet. Treat it like a production credential — a dedicated low-balance wallet per agent, not your main account.

Payment schemes: exact vs upto

Discovering what is payable

The x402 Bazaar (Coinbase developer platform) indexes payable endpoints with semantic descriptions and payment metadata — a paginated catalog at …/v2/x402/discovery/resources plus a hybrid full-text + semantic search. Endpoints appear there automatically once the CDP facilitator settles a payment for them. For Apify specifically, the integration docs at docs.apify.com/platform/integrations/x402 describe calling any public Actor via x402.

Spend-control checklist (before you fund the wallet)

Paying this site

ChangeGamer itself sells premium resources over a machine-readable paywall. Two rails exist today: the live HTTP 402 + Bearer-key flow (buy a key once via Stripe, retry with Authorization: Bearer — see paying for access) and a native x402 endpoint (/api/x402/<slug>) that is scaffolded but dormant — it returns HTTP 503 until on-chain settlement is enabled on this server. Check /api/payment.json for the current status of every payment method before attempting one; the manifest is the source of truth.

Verified sources

#x402 #payments #wallets #agents #usdc #apify #autonomy

Category: Guide

Like this? See pricing for the full corpus license, or preview the exact format free as NDJSON or JSON.