Skip to main content

Middleware names

Example server plugins that add instant paywall or payment logic via HTTP 402 to popular backend frameworks.
  • Express
  • Hono
  • Next.js
import { default as express } from "express";
import { express as middleware } from "@faremeter/middleware";
import { solana, evm } from "@faremeter/info";

const app = express();

app.get(
"/protected",
await middleware.createMiddleware({
facilitatorURL: "https://facilitator.corbits.io",
accepts: [
  solana.x402Exact({
    network: "devnet",
    asset: "USDC",
    amount: "10000",
    payTo: "1wjYK7B5esmte2HVpKHQYbAldad3Rw27ejW3UZjcCWc2",
  }),
  evm.x402Exact({
    network: "base-sepolia",
    asset: "USDC",
    amount: "10000",
    payTo: "0xf64e67d49C49dA9240ac43934327d015138C85Aa",
  }),
],
}),
(_, res) => {
return res.json({
  msg: "success",
});
},
);

app.listen();

Client names

Example wallets and agents that automate payments and access with seamless, programmable integration.
  • Crossmint
  • Ledger
  • Squads
import { createCrossmintWallet } from "@faremeter/wallet-crossmint";
import { createPaymentHandler } from "@faremeter/x-solana-settlement";
import { wrap as wrapFetch } from "@faremeter/fetch";

const wallet = await createCrossmintWallet(
  "devnet",
  crossmintApi,
  crossmintWallet,
);
const fetchWithPayer = wrapFetch(fetch, {
  handlers: [createPaymentHandler(wallet)],
});

const req = await fetchWithPayer(url);
Is your wallet missing support? Submit a PR or contact our team.

Blockchain names

Example networks for settling payments
  • Solana
  • Base
import { Connection, PublicKey } from "@solana/web3.js";
import { createLocalWallet } from "@faremeter/wallet-solana";
import { lookupKnownSPLToken } from "@faremeter/info/solana";
import {
  createPaymentHandler,
  lookupX402Network,
} from "@faremeter/payment-solana-exact";
import { wrap as wrapFetch } from "@faremeter/fetch";
import { clusterApiUrl } from "@solana/web3.js";

const network = "devnet";
const x402Network = lookupX402Network(network);
const usdcInfo = lookupKnownSPLToken(network, "USDC")!;
const connection = new Connection(clusterApiUrl(network));

const mint = new PublicKey(usdcInfo.address);
const wallet = await createLocalWallet(x402Network, keypair);
const fetchWithPayer = wrapFetch(fetch, {
  handlers: [createPaymentHandler(wallet, mint, connection)],
});

const req = await fetchWithPayer(url);
Don’t see your preferred blockchain supported? Submit a PR or contact our team.

Protocol names

  • Coinbase
  • Google
  • Stripe
  • Cloudflare
x402 by Coinbasex402 is an open payment standard that enables AI agents and web services to autonomously pay for API access, data, and digital services.By leveraging the long-reserved HTTP 402 ”Payment Required” status code, x402 eliminates the need for API keys, subscriptions, and manual payment processing, allowing real-time, machine-native transactions using stablecoins like USDC.
Learn more about Coinbase’s x402 protocol here