AI agents · HTTP 402

402 → pay → retry in under 10 minutes

Hit the live Next.js hard-lock demo (also listed on Coinbase Bazaar). Official x402 clients handle the challenge, sign a Base USDC payment, and retry with payment-signature. Same URL humans open in a browser.

Before you pay

Demo unlocks are $0.10 USDC on Base mainnet. Use a funded wallet that is not the publisher payout address — facilitators reject self-transfers.

1. Probe with curl — expect HTTP 402 and accepts[].

2. Run TypeScript or Python with EVM_PRIVATE_KEY. The client retries automatically.

3. Point the same snippet at your site once an adapter is on that URL (integrations).

Shipping this on your site?

Turn on a paywall — the agent catalog is generated from your rules, and Coinbase Bazaar listing follows the first settle. WordPress can publish /.well-known/ai-catalog.json on sync.

Find it on Bazaar

bash

curl "https://api.cdp.coinbase.com/platform/v2/x402/discovery/search?query=smidgen"

Install

bash

npm i @x402/fetch @x402/evm @x402/core viem

Pay Next.js hard-locked article

ts

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

const url = "https://next-demo.smidgen.io/premium/locked";
const key = process.env.EVM_PRIVATE_KEY as `0x${string}` | undefined;
if (!key) {
  throw new Error("Set EVM_PRIVATE_KEY to a funded Base wallet (0x…)");
}

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(key) });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

async function main() {
  const response = await fetchWithPayment(url, {
    headers: {
      Accept: "application/json, text/html;q=0.9,*/*;q=0.8",
      "User-Agent": "smidgen-agent-example/1.0",
    },
  });
  console.log("HTTP", response.status);
  console.log(await response.text());
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Run: EVM_PRIVATE_KEY=0x… npx tsx pay.ts