All Tools
Tools/Agent Payment Sandbox
🤖
BlockchainBeta

Agent Payment Sandbox

Run one AI-agent purchase over x402 from start to finish: the 402 quote, the wallet's policy check, the spend-permission pull, the signed EIP-3009 authorization, facilitator verification, settlement and finality. Then break it — inflated quote, look-alike token, spent budget, altered recipient, replay — and see which layer stops it.

Follows x402 specification · exact EVM scheme (EIP-3009)v2·verified Nov 2026— payment objects, verification order and reason codes follow the specification; signatures re-verified with eth-account 0.14.0; wallet-side checks are good practice, not protocol; balances, nonces and settlement are simulated

Pick a scenario
Works
Stopped by the wallet
Stopped by the contract
Stopped by the facilitator

The agent buys one API response for 0.25 USDC, well inside its limits.

Set-up
Paid 0.25 USDC. 6.75 USDC of this period’s allowance is left.
Spent before 3.00This payment 0.25Left today 6.75 of 10.00 USDC
What happens, step by step
  1. Resource server — passed
    Server answers 402 with a quote

    GET https://api.example.com/premium-data → 402 Payment Required: 0.25 USDC on eip155:8453, pay to 0x209693Bc6afc0C5328bA36FaF03C514EF312287C.

    PAYMENT-REQUIRED (decoded)
    {
      "x402Version": 2,
      "error": "PAYMENT-SIGNATURE header is required",
      "resource": {
        "url": "https://api.example.com/premium-data",
        "description": "Access to premium market data",
        "mimeType": "application/json"
      },
      "accepts": [
        {
          "scheme": "exact",
          "network": "eip155:8453",
          "amount": "250000",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
          "maxTimeoutSeconds": 60,
          "extra": {
            "name": "USD Coin",
            "version": "2"
          }
        }
      ]
    }
    PAYMENT-REQUIRED header
    eyJ4NDAyVmVyc2lvbiI6MiwiZXJyb3IiOiJQQVlNRU5ULVNJR05BVFVSRSBoZWFkZXIgaXMgcmVxdWlyZWQiLCJyZXNvdXJjZSI6eyJ1cmwiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbS9wcmVtaXVtLWRhdGEiLCJkZXNjcmlwdGlvbiI6IkFjY2VzcyB0byBwcmVtaXVtIG1hcmtldCBkYXRhIiwibWltZVR5cGUiOiJhcHBsaWNhdGlvbi9qc29uIn0sImFjY2VwdHMiOlt7InNjaGVtZSI6ImV4YWN0IiwibmV0d29yayI6ImVpcDE1NTo4NDUzIiwiYW1vdW50IjoiMjUwMDAwIiwiYXNzZXQiOiIweDgzMzU4OWZDRDZlRGI2RTA4ZjRjN0MzMkQ0ZjcxYjU0YmRBMDI5MTMiLCJwYXlUbyI6IjB4MjA5NjkzQmM2YWZjMEM1MzI4YkEzNkZhRjAzQzUxNEVGMzEyMjg3QyIsIm1heFRpbWVvdXRTZWNvbmRzIjo2MCwiZXh0cmEiOnsibmFtZSI6IlVTRCBDb2luIiwidmVyc2lvbiI6IjIifX1dfQ==
  2. Agent wallet — passed
    Wallet checks the quote against its policy

    All checks pass; the wallet may pay this quote.

    • ✓Scheme is supported. exact: pay precisely the quoted amount.
    • ✓Network is the one the budget is on. eip155:8453 (Base).
    • ✓Asset is the chain’s USDC contract. 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 is USDC on Base.
    • ✓Asset is the token the budget covers. Same contract as the spend permission.
    • ✓EIP-712 domain matches the token. name “USD Coin”, version “2”.
    • ✓Payee is allowed. 0x209693Bc6afc0C5328bA36FaF03C514EF312287C is on the allowlist.
    • ✓Amount is within the per-payment cap. 0.25 USDC ≤ cap 2 USDC.
  3. Owner account — passed
    Agent pulls the amount with its spend permission

    0.25 USDC moves from the owner’s account to the agent. Spent this period: 3.25 USDC of 10 USDC.

    Call
    SpendPermissionManager.spend(permission, 250000)  // spender = 0x7c8BFaDd9Ca02942af588949d738494126B5d78D
  4. Agent wallet — passed
    Agent signs an EIP-3009 authorization

    TransferWithAuthorization: 0.25 USDC from 0x7c8BFaDd9Ca02942af588949d738494126B5d78D to 0x209693Bc6afc0C5328bA36FaF03C514EF312287C, valid for 60 s, single-use nonce.

    PAYMENT-SIGNATURE (decoded)
    {
      "x402Version": 2,
      "resource": {
        "url": "https://api.example.com/premium-data",
        "description": "Access to premium market data",
        "mimeType": "application/json"
      },
      "accepted": {
        "scheme": "exact",
        "network": "eip155:8453",
        "amount": "250000",
        "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        "payTo": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
        "maxTimeoutSeconds": 60,
        "extra": {
          "name": "USD Coin",
          "version": "2"
        }
      },
      "payload": {
        "signature": "0x06bd9db93c7d9b0b222875950ce085fde7463fd37a37429b83bc1eb5d8df09fe7a57694e6d3701167355b069d926d1f3c9af7b5baffd01246cee1ba39b0f8d271b",
        "authorization": {
          "from": "0x7c8BFaDd9Ca02942af588949d738494126B5d78D",
          "to": "0x209693Bc6afc0C5328bA36FaF03C514EF312287C",
          "value": "250000",
          "validAfter": "1794563400",
          "validBefore": "1794564060",
          "nonce": "0x79ba7ada898e9c8cc3928cc6b298ade1a1d1ff2c4d6f3c373f903549c72b8b44"
        }
      }
    }
    PAYMENT-SIGNATURE header
    eyJ4NDAyVmVyc2lvbiI6MiwicmVzb3VyY2UiOnsidXJsIjoiaHR0cHM6Ly9hcGkuZXhhbXBsZS5jb20vcHJlbWl1bS1kYXRhIiwiZGVzY3JpcHRpb24iOiJBY2Nlc3MgdG8gcHJlbWl1bSBtYXJrZXQgZGF0YSIsIm1pbWVUeXBlIjoiYXBwbGljYXRpb24vanNvbiJ9LCJhY2NlcHRlZCI6eyJzY2hlbWUiOiJleGFjdCIsIm5ldHdvcmsiOiJlaXAxNTU6ODQ1MyIsImFtb3VudCI6IjI1MDAwMCIsImFzc2V0IjoiMHg4MzM1ODlmQ0Q2ZURiNkUwOGY0YzdDMzJENGY3MWI1NGJkQTAyOTEzIiwicGF5VG8iOiIweDIwOTY5M0JjNmFmYzBDNTMyOGJBMzZGYUYwM0M1MTRFRjMxMjI4N0MiLCJtYXhUaW1lb3V0U2Vjb25kcyI6NjAsImV4dHJhIjp7Im5hbWUiOiJVU0QgQ29pbiIsInZlcnNpb24iOiIyIn19LCJwYXlsb2FkIjp7InNpZ25hdHVyZSI6IjB4MDZiZDlkYjkzYzdkOWIwYjIyMjg3NTk1MGNlMDg1ZmRlNzQ2M2ZkMzdhMzc0MjliODNiYzFlYjVkOGRmMDlmZTdhNTc2OTRlNmQzNzAxMTY3MzU1YjA2OWQ5MjZkMWYzYzlhZjdiNWJhZmZkMDEyNDZjZWUxYmEzOWIwZjhkMjcxYiIsImF1dGhvcml6YXRpb24iOnsiZnJvbSI6IjB4N2M4QkZhRGQ5Q2EwMjk0MmFmNTg4OTQ5ZDczODQ5NDEyNkI1ZDc4RCIsInRvIjoiMHgyMDk2OTNCYzZhZmMwQzUzMjhiQTM2RmFGMDNDNTE0RUYzMTIyODdDIiwidmFsdWUiOiIyNTAwMDAiLCJ2YWxpZEFmdGVyIjoiMTc5NDU2MzQwMCIsInZhbGlkQmVmb3JlIjoiMTc5NDU2NDA2MCIsIm5vbmNlIjoiMHg3OWJhN2FkYTg5OGU5YzhjYzM5MjhjYzZiMjk4YWRlMWExZDFmZjJjNGQ2ZjNjMzczZjkwMzU0OWM3MmI4YjQ0In19fQ==
    Open this header in the x402 decoder →
  5. Facilitator — passed
    Facilitator verifies the payment

    Valid: signature, balance, amount, validity window, recipient, token and network all match.

    • ✓Signature recovers to authorization.from. EIP-712 signature recovers to authorization.from.
    • ✓Payer holds enough of the asset. Balance 0.25 USDC covers 0.25 USDC.
    • ✓Value equals the required amount. 0.25 USDC.
    • ✓Authorization is already valid. validAfter 1794563400 has passed.
    • ✓Authorization has not expired. 59 s left before validBefore.
    • ✓Recipient is the required payTo. 0x209693Bc6afc0C5328bA36FaF03C514EF312287C
    • ✓Token and network match the requirement. eip155:8453, 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913.
    • ✓Simulated transferWithAuthorization succeeds. The call would succeed against current state.
    POST /verify response
    {
      "isValid": true,
      "payer": "0x7c8BFaDd9Ca02942af588949d738494126B5d78D"
    }
  6. Facilitator — passed
    Facilitator settles; server returns the resource

    The facilitator submits transferWithAuthorization and pays the gas; 0.25 USDC moves from the agent to 0x209693Bc6afc0C5328bA36FaF03C514EF312287C. The server answers 200 with the data.

    PAYMENT-RESPONSE (decoded) — transaction hash is simulated
    {
      "success": true,
      "transaction": "0x9d02ae929a1f268b9ce1183e650a0f897a6871d4cceea77e0f9aed4a09a1c3d0",
      "network": "eip155:8453",
      "payer": "0x7c8BFaDd9Ca02942af588949d738494126B5d78D"
    }
    PAYMENT-RESPONSE header
    eyJzdWNjZXNzIjp0cnVlLCJ0cmFuc2FjdGlvbiI6IjB4OWQwMmFlOTI5YTFmMjY4YjljZTExODNlNjUwYTBmODk3YTY4NzFkNGNjZWVhNzdlMGY5YWVkNGEwOWExYzNkMCIsIm5ldHdvcmsiOiJlaXAxNTU6ODQ1MyIsInBheWVyIjoiMHg3YzhCRmFEZDlDYTAyOTQyYWY1ODg5NDlkNzM4NDk0MTI2QjVkNzhEIn0=
  7. Chain — passed
    Merchant waits for finality

    Base: ≈ 20 min. Final once the batch holding the block is posted to Ethereum and that L1 block is finalized — about 20 min (“safe”, batch on L1, after about 2 min). Checkout on the 2 s L2 block (the sequencer is the only reorg risk); treasury and settlement on “finalized”.

Who is who
Owner account
0x1111111111111111111111111111111111111111 — smart wallet holding the funds
Agent wallet
0x7c8BFaDd9Ca02942af588949d738494126B5d78D — spender of the permission, signs the payments
Merchant
0x209693Bc6afc0C5328bA36FaF03C514EF312287C — payTo in an honest quote
Budget
10.00 USDC per day on Base, 2026-11-13T00:00:00Z → 2026-12-13T00:00:00Z
Time of purchase
2026-11-13T10:00:00Z

The agent’s key is a published throwaway derived from a fixed label, so the signatures are real and repeatable. Do not send funds to it. Balances, nonce state and the settlement transaction are simulated; no chain or server is contacted.

Three layers, three different stops

An agent payment has more than one place where it can be refused, and each one protects against something different. The wallet policy runs before anything is signed: it is where a bad quote — too large, the wrong token, the wrong chain, an unknown payee — is caught, and it is the only layer that can see intent. The spend permission is enforced by a contract the agent cannot change: even if the agent’s software is compromised, it cannot pull more than the owner granted. The facilitator protects the merchant: it checks that the signed authorization is genuine, funded, in time, unaltered and unused before the server releases anything.

The sandbox models the agent as its own wallet that holds only what it has pulled. Each purchase is funded by one spend() call on Coinbase’s SpendPermissionManager for exactly the quoted amount, then paid with an EIP-3009 authorization signed by the agent. Other designs keep a float in the agent’s wallet or have a smart account sign directly; the three layers are the same. The Agent Wallets guide compares them.

What is checked against a specification

The PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE objects follow x402 v2. Facilitator checks run in the order of the exact EVM scheme — signature, balance, amount and validity window, token and network, then a simulated transferWithAuthorization — and the reason codes are the specification’s. Which code a facilitator returns when the simulation fails (for example on a reused nonce) is implementation-specific; the sandbox shows invalid_transaction_state. The wallet-side checks are good practice, not part of the protocol: x402 does not tell a client what to refuse.

Questions

Why did the facilitator not catch the inflated quote?

Because nothing was wrong with it from the protocol’s point of view. A facilitator verifies that the payment matches the quote, not that the quote is reasonable. Only the payer’s side knows what the purchase should cost.

What happens to money pulled for a payment that is then rejected?

It stays in the agent’s wallet and still counts against the period’s allowance. The agent can use it for the retry; the owner can sweep it back. An unused EIP-3009 authorization simply expires at validBefore.

Can a merchant replay a signed payment?

No. Each authorization carries a random 32-byte nonce that the token contract records when it settles; a second submission reverts. A different payment needs a new signature.

Something wrong or missing? Report a problem— we check reports against the specs and fix them.