๐Ÿ“… Historical page. This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail. โ†’ See current

3 Lines of Code: Make Your AI Agent Pay for APIs with USDC

August 3, 2026 ยท minia2a ยท 4 min read ยท Tutorial

Your AI agent can reason, plan, and execute. But can it pay? Can it autonomously buy the data it needs โ€” token prices, wallet intelligence, gas estimates โ€” without a human pulling out a credit card?

With x402 and minia2a, the answer is yes. Here's how to do it in three lines of code.

The Problem

Traditional API access means API keys, signup forms, rate limits, and monthly subscriptions. AI agents can't fill out signup forms. They can't pass credit checks. They can't negotiate SaaS contracts.

But they can sign a transaction.

x402 (HTTP 402 Payment Required) lets your agent pay for API calls the same way it makes them: programmatically. No human in the loop.

Line 1: Register Your Agent (Get a Wallet)

Step 1
# Self-custody: generate your own wallet, then sign EIP-191 "minia2a register: ".
curl -s -X POST https://minia2a.uk/api/v1/register-simple \
  -H "Content-Type: application/json" \
  -d '{"name":"my-first-agent","wallet":"0xYOUR_WALLET","signature":"0xYOUR_SIGNATURE"}'
{ "ok": true, "name": "my-first-agent", "trials": 5, "message": "5 free trial calls granted" }

That's it. Your agent is registered with 5 free trial calls (worth ~$2.50 in API calls). You keep your own self-custody wallet โ€” the platform never mints or holds your key. No KYC. No gas fees. No waiting.

Line 2: Call a Paid API

Step 2
export WALLET=0xYOUR_WALLET SERVICE=x402-time TS=$(date +%s)
export SIG=0xYOUR_SIGNATURE   # EIP-191 personal_sign of: minia2a trial:$WALLET:$SERVICE:$TS
curl "https://minia2a.uk/x402/proxy/x402-time?wallet=$WALLET" \
  -H "X-Wallet-Signature: $SIG" -H "X-Trial-Timestamp: $TS"
{"ok":true,"result":{"utc":"2026-08-03T05:30:31.722Z","unix":1785735031}}

Your agent just paid for an API call. Credits were deducted from your balance. The response includes the data you asked for.

No API key. No subscription. No credit card. Just: agent wants data โ†’ agent pays โ†’ agent gets data.

Line 3: Check the State of the Network

Step 3
curl -s "https://minia2a.uk/api/stats"

Note: V5 removed the per-wallet balance endpoint โ€” GET /api/v1/credits no longer exists (it returns 404). Your agent's trial state comes back inside each 402 response it receives, and platform-wide numbers live at /api/stats. Your agent is now a paying customer of the API economy.

What Can Your Agent Pay For?

minia2a lists 1,600+ x402-enabled services your agent can call right now:

ServiceWhat It DoesPrice
x402-timePrecise UTC timestamp$0.001
x402-gasReal-time gas prices across chains$0.003
x402-token-securityToken contract audit (honeypot, tax, ownership)$0.005
x402-wallet-intelWallet age, activity, PnL, tags$0.005
x402-web-scrapeScrape any webpage, clean output$0.005
x402-ens-resolveResolve ENS names โ†’ addresses$0.001
x402-funding-ratePerpetual funding rates across exchanges$0.003
x402-sentimentCrypto sentiment analysis$0.003

Full catalog: curl https://minia2a.uk/api/services

From Python: A Real Agent

Here's a Python agent that researches a token before trading โ€” it calls 3 paid APIs and pays for each:

import requests, os

WALLET = os.environ["MINIA2A_WALLET"]
BASE = "https://minia2a.uk/x402/proxy"

def call(service, **params):
    params["wallet"] = WALLET
    r = requests.get(f"{BASE}/{service}", params=params)
    return r.json()

token = "0x1234..."
security = call("x402-token-security", token=token)
funding  = call("x402-funding-rate", symbol="ETH")
sentiment = call("x402-sentiment", symbol="ETH")

print(f"Token safety: {security.get('result',{}).get('isHoneypot')}")
print(f"ETH funding: {funding.get('result',{}).get('rate')}")
print(f"ETH sentiment: {sentiment.get('result',{}).get('sentiment')}")

# (V5 has no per-wallet balance endpoint โ€” /api/v1/credits returns 404.
#  Remaining trial calls come back in each 402 response body.)

When Credits Run Out

After 5 free calls (or when you need more), your agent hits an HTTP 402:

HTTP 402 Payment Required { "_registration_required": true, "message": "Credits exhausted. Pay with USDC on Base.", "payment": { "amount": "0.005", "token": "USDC", "chain": "Base", "recipient": "0xf16F0882de08315B438E9f3a2Abfb2d2E5d94ECA" } }

Your agent sends $0.005 USDC on Base โ†’ retries the request โ†’ gets the data. The whole flow takes under 2 seconds. Or use @x402/fetch (npm) which handles the 402 โ†’ pay โ†’ retry cycle automatically:

import { x402Fetch } from "@x402/fetch";
const res = await x402Fetch("https://minia2a.uk/x402/proxy/x402-gas");
const data = await res.json();

What Just Happened?

In three lines of code, you gave your AI agent:

  1. A wallet โ€” self-custody, on Base L2, no gas fees
  2. Purchasing power โ€” 5 free trial calls to start, then pay-per-call with USDC
  3. API access โ€” 180 services, any of which your agent can call and pay for autonomously

Your agent is no longer just a reasoning engine. It's an economic actor. It earns. It spends. It decides what data is worth paying for.

Try it now: Paste the 3 curl commands above into your terminal. In 30 seconds, your agent has a wallet, credits, and has made its first paid API call. No signup. No waiting.

minia2a is a live marketplace. 180 services. USDC on Base. Pay per call. minia2a.uk