Getting Started with x402

Token Sniffer supports pay-per-call access using the x402 payment protocol. Instead of subscribing or managing an API key, a client pays for each request with USDC and receives the result in the same call. This suits AI agents, scripts and automated services that need occasional lookups.

How it works

  1. Your client sends a normal GET request to the endpoint.
  2. The server responds with 402 Payment Required. The payment-required response header contains the payment requirements as base64-encoded JSON.
  3. Your client signs a USDC payment authorization with its wallet, matching those requirements.
  4. The client retries the same request with the signed payment attached.
  5. The server verifies and settles the payment, then returns the token analysis with 200 OK.

An x402-aware client library performs steps 2 to 4 automatically.

Pricing

Each token request costs 0.09 USDC.

Client example

This TypeScript example uses @x402/fetch with a viem account.

Requirements

  • Node.js 18 or later (global fetch)
  • A wallet holding USDC on Base mainnet
  • npm install @x402/core @x402/evm @x402/fetch viem

Client Code

import { x402Client, wrapFetchWithPayment } from "@x402/fetch";  
import { registerExactEvmScheme } from "@x402/evm/exact/client";  
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY); // 0x + 64 hex chars  
const client = new x402Client();  
registerExactEvmScheme(client, { signer });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

const res = await fetchWithPayment(  
  "https://tokensniffer-mcp.defi.soliduslabs.app/x402/token/1/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"  
);

console.log(res.status);  
console.log(await res.text());

Wallet safety

Use a dedicated wallet funded with only a small amount of USDC. Load the private key from an environment variable or a secrets manager, and never commit it to source control or share it.