DEV Community

Hiroshi Ichiyanagi
Hiroshi Ichiyanagi

Posted on

Let your AI agent autonomously buy data — x402 + gasless prepaid + MCP on Base

AI agents can now pay for APIs by themselves. Here’s a live endpoint that does it end-to-end on Base (USDC), and how to plug it into your agent in minutes.
The problem
HTTP 402 (“Payment Required”) lets an API charge per call in crypto. But most x402 endpoints make the agent send an on-chain transaction every single call — gas + latency + a signature each time. That’s fine for a one-off, terrible for an agent making hundreds of calls.
The fix: deposit once, then gasless
https://x402.obolpay.xyz adds a prepaid balance: the agent deposits USDC once, then pays per call with an off-chain signed voucher — no on-chain tx, no gas, instant.

1) discover + free preview (no spend)

import requests
BASE = "https://x402.obolpay.xyz"
print(requests.get(f"{BASE}/.well-known/x402").json()) # price, token, network, capabilities
print(requests.get(f"{BASE}/api/v1/protected-data").json()) # HTTP 402 with a FREE preview

2) what's in demand right now?

print(requests.get(f"{BASE}/stats").json()["selected_product"]) # market-selected best category

3) gasless pay-per-call after one topup (see /account/{address} for the voucher_message to sign)

header X-Account-Address / X-Account-Nonce / X-Account-Voucher -> instant, gasless, metered

Why agents keep coming back
• Free preview → evaluate before paying (no blind spend).
• Gasless prepaid → one deposit, then unlimited cheap calls.
• Delta delivery (X-Since-Seq) → only new data, saves your context tokens.
• Signed receipts → verifiable proof-of-purchase (/verify-receipt).
• Freshness SLA → stale data is auto-refunded to your balance.
Plug into Claude / any MCP agent
Add the MCP server (/mcp-server.py) — tools: discover / preview / purchase / balance / topup / spend_gasless / verify_receipt. Your agent can now discover, evaluate, pay, and fetch on its own.
Try it
Endpoint: https://x402.obolpay.xyz · Client: curl https://x402.obolpay.xyz/client.py · Manifest: /.well-known/x402.
Built on x402 + Base. Feedback welcome.

Top comments (0)