Dev.to AI 🤖 Ai 👁 0 📖 2 min read

Check a payTo before your agent pays it: a $0.01 x402 endpoint for Base

x402 makes it trivial for an agent to pay an API it has never seen. The 402 response tells it how much and to whom, it signs, done. What it doesn't tell the agent is anything about who it is paying. So I built a small e

x402 makes it trivial for an agent to pay an API it has never seen. The 402 response tells it
how much and to whom, it signs, done. What it doesn't tell the agent is anything about who it
is paying.

So I built a small endpoint that answers one question about any Base address, for one cent:

GET https://x402.sumeria.ar/v1/base/perfil/{address}

It returns plain facts, with the block number they were read at:

  • type: EOA, EOA with an EIP-7702 delegation, or contract
  • nonce, ETH balance, USDC balance
  • USDC flow over the last 7 days: received, sent, number of transfers, distinct counterparties and distinct payers

No scores, no LLM, no "risk rating". An address that was created yesterday and has never
received USDC from anyone looks very different from one with a few hundred distinct payers
this week, and your agent can decide what that means for itself.

Paying from an agent with @x402/fetch

import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

// The agent's own wallet, with a little USDC on Base. No ETH needed: the facilitator pays gas.
const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY as `0x${string}`);

const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const payTo = "0x..."; // the address you are about to pay
const res = await fetchWithPayment(`https://x402.sumeria.ar/v1/base/perfil/${payTo}`);
const profile = await res.json();

if (profile.usdc7d.pagadoresDistintos === 0) {
  // nobody has paid this address in a week: maybe look twice
}

The response looks like this (field names are in Spanish; the shape is in the Bazaar listing):

{
  "direccion": "0x…",
  "red": "eip155:8453",
  "tipo": "eoa",
  "nonce": 412,
  "saldoEth": "0.0123",
  "saldoUsdc": "57.31",
  "usdc7d": {
    "recibido": "18.42",
    "enviado": "3.1",
    "transferencias": 1904,
    "contrapartesDistintas": 211,
    "pagadoresDistintos": 207,
    "desdeBloque": "36000001",
    "completo": true
  },
  "bloque": "36302400"
}

completo: false means the address moved more than 5,000 USDC transfers in one direction in
the window; you get the figures for what was read instead of a 30-second wait.

Details

  • Price: $0.01 in USDC on Base, exact scheme (EIP-3009), CDP facilitator. Listed in the x402 Bazaar as "Perfil de contraparte en Base".
  • Latency: about 2 s typical, under 5 s for very busy addresses.
  • Input: only ^0x[0-9a-fA-F]{40}$. A malformed address gets a 400 before any 402, so it is never charged.
  • No charge on errors: if the chain read fails you get a 502 and nothing is settled.
  • No wallet keys on the server: it only knows the address it gets paid to.
  • Humans: there is a small page at https://x402.sumeria.ar/pagar to try it from MetaMask (capped at 0.01 USDC).

If you build agents that pay other x402 services, I'd like to know whether this is the
question you'd want answered before paying, or a different one.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.