Humans pay in the browser. Bots and agents hit the same URL and get a payment challenge — then unlock after USDC settle.
Agent proof — 402 → pay → retry
Copy TypeScript or Python against Next.js hard-locked article. These URLs are in Coinbase Bazaar — search smidgen, then pay with the snippet below. Same link works in a browser for humans.
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);
});