01What it is
Agentic layers / payments layer

Payments Layer

x402 pay-per-call — settle on chain in stablecoins.

Agents pay when they use tools and APIs, not on a flat monthly API plan. Web3 Agent Kit runs x402 verify-and-settle through network-aware facilitators — x402.org on testnet, Coinbase CDP on mainnet — so every priced MCP call can finish with an on-chain receipt.

MCP · tools/callx402 FACILITATORON CHAINget_token_price402paymentRequiredverifysettle · exactUSDCreceiptclient walletsign payloadpaid_fetch · external HTTPS402 probe → pay → dataPER CALLx402 v2paymentReceipt
02Paths
Three payment paths

Kit-priced MCP tools

Fixed-price tools like get_token_price at $0.001. Spend policy (optional) → payment requirements → verify → execute → settle → ledger entry.

External x402 APIs

paid_fetch probes HTTPS resources, surfaces 402 and PAYMENT-REQUIRED, retries with x402 v2 paymentPayload, returns response data plus payment_details.

Wallet transfers

transfer prepares unsigned USDC, USDC.e, native, or Solana stablecoin txs for funding or payouts. Signing stays in your wallet (not x402, but same assets agents use to pay).

Built on @x402/core, @x402/evm (exact EVM scheme), and @coinbase/x402 for CDP mainnet facilitator auth. paid_fetch is x402-only in this build (no MPP/Tempo payment protocol).

03Why
Why it matters
06
$0.001
Pay only for what runs.
Each priced call carries its own payment requirement; no standing API subscription required for agent tool usage.
testmain
Testnet to mainnet.
Facilitator selection follows X402_NETWORK automatically: public x402.org for known testnets; Coinbase CDP facilitator for production mainnet with your CDP API credentials.
$USDC
Stablecoins on chain.
Exact EVM settlement on the configured CAIP-2 network; discovery and Bazaar entries commonly filter on usdc and network.
402
Agent-native loop.
Probe → Payment Required → sign paymentPayload → retry is a first-class MCP flow; hosts can automate or gate with approval UI.
Auditable outcomes.
Successful kit payments return paymentReceipt in the MCP result; spend ledger tracks kit tool totals; mcp_tool_call_logs records payment_required and settled ok statuses per tenant.
sign
No custody in the kit.
Client signs paymentPayload. Facilitator verifies and settles. Same model for kit tools and paid_fetch.
04Facilitators
Facilitator tiers (network-aware)

The kit picks the facilitator from X402_NETWORK — no manual URL switching per environment when you change network id.

Testnet tier

x402.org

Used when X402_NETWORK is a known testnet CAIP-2 id: eip155:84532 (Base Sepolia, default), solana devnet, eip155:4801.

X402_TESTNET_FACILITATOR_URL

default https://x402.org/facilitator

Legacy X402_FACILITATOR_URL accepted as fallback when testnet URL is unset.

Mainnet tier

Coinbase CDP

Used for all other X402_NETWORK values (e.g. Base mainnet eip155:8453). Requires CDP_API_KEY_ID and CDP_API_KEY_SECRET via @coinbase/x402.

https://api.cdp.coinbase.com/platform/v2/x402

Kit-priced MCP tools use ExactEvmScheme on the configured EVM network.

05Kit x402
How x402 works (kit MCP tools)
  1. tools/call without paymentPayload

    For priced tools, router evaluates spend policy, resolves payTo (X402_PAY_TO_ADDRESS or agent evmAddress), builds accepts[] via facilitator. Returns a Payment Required error with data.paymentRequirements (scheme: exact, network, payTo, price).

  2. Client signs paymentPayload

    Host wallet or signing service produces x402 v2 paymentPayload matching an accept. The kit never holds private keys.

  3. tools/call with paymentPayload in params

    Facilitator verifies → tool executes → facilitator settles on chain.

  4. MCP success response

    result.content carries tool output (JSON text). result.paymentReceipt carries settlement metadata from facilitator.

  5. Ledger (optional)

    If spend policy is enabled, agent_spend_ledger records USD micro-amount with idempotent requestKey (SHA-256 of agent + tool + payload).

06External
How x402 works (paid_fetch)
  1. Probe (no paymentPayload)

    paid_fetch calls the HTTPS URL. On a Payment Required response from the HTTPS endpoint (or v1 JSON body), MCP returns a Payment Required error with upstream requirements.

  2. Pay and retry

    Client signs x402 v2 paymentPayload only (v1 rejected). Second call verifies via facilitator, adds PAYMENT-SIGNATURE headers, executes HTTP request.

  3. Settlement

    Prefer PAYMENT-RESPONSE / X-PAYMENT-RESPONSE from origin; else settle via facilitator. Response includes payment_made, payment_details, status, ok, data.

Variable pricing — amount comes from the third party. Trust spend policy does not cap paid_fetch; use discover_services maxUsdPrice operationally.

07Config
Pay-to, network & environment
X402_NETWORK

CAIP-2 network (default eip155:84532); drives facilitator tier automatically

X402_TESTNET_FACILITATOR_URL

Override for testnet facilitator (default https://x402.org/facilitator)

CDP_API_KEY_ID / CDP_API_KEY_SECRET

Required for mainnet Coinbase CDP facilitator

X402_PAY_TO_ADDRESS

Optional fixed pay-to for kit tools; else agent evmAddress

Discovery alignment: discover_services filters — network, asset (usdc), scheme, payTo, maxUsdPrice — so agents find services that match your payment rail before paid_fetch.

08Surfaces
Payment surfaces
  • get_token_priceFixed $0.001/call · full x402 + optional spend policy + ledger
  • paid_fetchThird-party x402 HTTPS · variable price · v2 paymentPayload only
  • transferNot x402 — unsigned same-chain transfers to fund paying wallets
  • discover_services / get_serviceFree catalog browse; returns paymentsProtocolConfig and accepts before spend

Micropayments (x402): exact EVM scheme on X402_NETWORK. Transfers (wallet rail): USDC / USDC.e on ethereum, base, sepolia, polygon, arbitrum-one, monad, tempo, and Solana USDC for prefunding pay-to wallets. Sender pays native gas unless your wallet stack sponsors it.

09Audit
Observability & receipts
  • mcp_tool_call_logs

    Every tools/call logged with status: ok, error, payment_required, spend_policy_denied, auth_error, invalid_params. Args and response JSON stored (credentials hashed).

    GET /mcp/tool-call-logs?agentId=&toolName=&status=payment_required&from=&to=
  • agent_spend_ledger

    Per-agent USD micro totals for Trust Layer budgets after successful kit tool settlement.

JSON-RPC codes (payment-related)

  • Payment Required

    x402 payment required

  • Spend Policy Denied

    Trust Layer budget exceeded

  • Resolution Error

    Tool or payTo resolution error

10Design
Design principles
  • Network picks facilitator

    One X402_NETWORK config switches testnet vs mainnet settlement infrastructure — fewer misconfigurations between dev and prod.

  • Verify before execute

    Kit tools run priced logic only after facilitator verification succeeds.

  • Two-step payment UX

    paymentRequired first, paymentPayload second — natural pause for approval UI.

  • No custody in the kit

    Client signs; facilitators verify and settle; payTo can be agent wallet or platform override.

  • Idempotent accounting

    Ledger requestKey deduplication; tool call logs for operational audit.

11Stack
How it fits the other layers
See all agentic layers →
12Integrate
For developers

Dependencies: @x402/core, @x402/evm, @coinbase/x402. Env: X402_NETWORK, X402_TESTNET_FACILITATOR_URL, CDP_API_KEY_*, X402_PAY_TO_ADDRESS.

# Testnet (default Base Sepolia)
X402_NETWORK=eip155:84532
X402_TESTNET_FACILITATOR_URL=https://x402.org/facilitator
# CDP keys not required
Coinbase CDP x402 Bazaar docs →
13FAQ
FAQ
Do I need CDP API keys on testnet?

No. Testnet X402_NETWORK values use the public x402.org facilitator. CDP_API_KEY_ID and CDP_API_KEY_SECRET are required when X402_NETWORK is mainnet.

What changed from a single X402_FACILITATOR_URL?

Facilitator is chosen by network tier. Use X402_TESTNET_FACILITATOR_URL for testnet override; mainnet uses Coinbase CDP automatically.

Does the kit support MPP payments?

MCP paid_fetch is x402-only (no MPP/Tempo payment protocol). USDC transfers on Tempo and other chains use the transfer tool separately.

Who receives kit tool payments?

X402_PAY_TO_ADDRESS if set; otherwise the session agent's bound evmAddress.

What response means pay me?

Payment Required. Budget blocks use Spend Policy Denied (Trust Layer).

Can I see payment attempts in logs?

Yes. GET /mcp/tool-call-logs with status=payment_required or filter by toolName and agentId.

14Start

Per-call pricing for agents. Testnet to mainnet facilitators. x402 verify, settle, and receipt — built into MCP.