Go from zero to first paid call in under 5 minutes.
No payment needed:
curl https://api.cybersecurity-japan.com/demo/snapshot
Install x402-fetch:
npm install x402-fetch viem
Create snapshot.mjs:
import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { baseSepolia } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY");
const walletClient = createWalletClient({
account,
chain: baseSepolia,
transport: http(),
});
const fetchWithPayment = wrapFetchWithPayment(fetch, walletClient);
const res = await fetchWithPayment(
"https://api.cybersecurity-japan.com/v1/snapshot",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ url: "https://example.com" }),
}
);
console.log(await res.json());
node snapshot.mjs
Replace baseSepolia with base from viem/chains. Ensure your wallet holds USDC on Base.
Use the Circle USDC faucet to get free testnet USDC on Base Sepolia.
Full API reference →