x402 Echo Merchant

Instantly test the x402 protocol for pay-per-use APIs.
Perfect for agentic and micro transactions.

Live endpoints. Real payments. 100% free.

Quickstart Code Snippets

Install
npm install x402-fetch
Base Mainnet
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { wrapFetchWithPayment } from "x402-fetch";
import { base } from "viem/chains";

// Create a wallet client
const account = privateKeyToAccount("0xYourPrivateKey");
const client = createWalletClient({
  account,
  transport: http(),
  chain: base,
});

// Wrap the fetch function with payment handling
const fetchWithPay = wrapFetchWithPayment(fetch, client);

// Make a request that may require payment
console.log("making request + payment");
const response = await fetchWithPay(
  "https://x402.payai.network/api/base/paid-content",
  {
    method: "GET",
  }
);

const data = await response.text();
console.log(data);
Base Sepolia
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { wrapFetchWithPayment } from "x402-fetch";
import { baseSepolia } from "viem/chains";

// Create a wallet client
const account = privateKeyToAccount("0xYourPrivateKey");
const client = createWalletClient({
  account,
  transport: http(),
  chain: baseSepolia,
});

// Wrap the fetch function with payment handling
const fetchWithPay = wrapFetchWithPayment(fetch, client);

// Make a request that may require payment
console.log("making request + payment");
const response = await fetchWithPay(
  "https://x402.payai.network/api/base-sepolia/paid-content",
  {
    method: "GET",
  }
);

const data = await response.text();
console.log(data);

Resources