Middleware names
Example server plugins that add instant paywall or payment logic via HTTP 402 to popular backend frameworks.- Express
- Hono
- NestJS
Copy
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.dev",
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();
Copy
import { serve } from "@hono/node-server";
import { Hono } from "hono";
import { hono as middleware } from "@faremeter/middleware";
import { solana, evm } from "@faremeter/info";
const app = new Hono();
app.get(
"/protected",
await middleware.createMiddleware({
facilitatorURL: "https://facilitator.corbits.dev",
accepts: [
solana.x402Exact({
network: "devnet",
asset: "USDC",
amount: "10000",
payTo: "1wjYK7B5esmte2HVpKHQYbAldad3Rw27ejW3UZjcCWc2",
}),
evm.x402Exact({
network: "base-sepolia",
asset: "USDC",
amount: "10000",
payTo: "0xf64e67d49C49dA9240ac43934327d015138C85Aa",
}),
],
}),
(c) => {
return c.json({
msg: "success",
});
},
);
serve(app, (info) => {
console.log(`Listening on http://localhost:${info.port}`);
});
Copy
import type { MiddlewareConsumer, NestModule } from "@nestjs/common";
import { express as middleware } from "@faremeter/middleware";
import { solana, evm } from "@faremeter/info";
export class AppModule implements NestModule {
async configure(consumer: MiddlewareConsumer) {
const faremeterMiddleware = await middleware.createMiddleware({
facilitatorURL: "https://facilitator.corbits.dev",
accepts: [
solana.x402Exact({
network: "devnet",
asset: "USDC",
amount: "10000",
payTo: "1wjYK7B5esmte2HVpKHQYbAldad3Rw27ejW3UZjcCWc2",
}),
evm.x402Exact({
network: "base-sepolia",
asset: "USDC",
amount: "10000",
payTo: "0xf64e67d49C49dA9240ac43934327d015138C85Aa",
}),
],
});
consumer.apply(faremeterMiddleware).forRoutes("protected");
}
}
Client names
Example wallets and agents that automate payments and access with seamless, programmable integration.- Crossmint
- Ledger
- Squads
Copy
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);
Copy
import {
createLedgerSolanaWallet,
selectLedgerAccount,
createReadlineInterface,
} from "@faremeter/wallet-ledger";
import { createPaymentHandler } from "@faremeter/x-solana-settlement";
import { wrap as wrapFetch } from "@faremeter/fetch";
const ui = await createReadlineInterface(process);
const selected = await selectLedgerAccount(ui, "solana", 5);
const ledgerWallet = await createLedgerSolanaWallet("devnet", selected!.path);
const fetchWithPayer = wrapFetch(fetch, {
handlers: [createPaymentHandler(ledgerWallet)],
});
const req = await fetchWithPayer(url);
await ledgerWallet.disconnect();
await ui.close();
Copy
import { clusterApiUrl, Connection } from "@solana/web3.js";
import { wrap as wrapFetch } from "@faremeter/fetch";
import { createSquadsWallet } from "@faremeter/wallet-solana-squads";
import { createPaymentHandler } from "@faremeter/x-solana-settlement";
const network = "devnet";
const connection = new Connection(clusterApiUrl(network), "confirmed");
const wallet = await createSquadsWallet(
network,
connection,
keypair,
multisigPda,
squadMember,
);
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
Copy
import { Connection, PublicKey, clusterApiUrl } from "@solana/web3.js";
import { createLocalWallet } from "@faremeter/wallet-solana";
import { lookupKnownSPLToken } from "@faremeter/info/solana";
import { createPaymentHandler } from "@faremeter/payment-solana/exact";
import { wrap as wrapFetch } from "@faremeter/fetch";
const network = "devnet";
const usdcInfo = lookupKnownSPLToken(network, "USDC")!;
const connection = new Connection(clusterApiUrl(network));
const mint = new PublicKey(usdcInfo.address);
const wallet = await createLocalWallet(network, keypair);
const fetchWithPayer = wrapFetch(fetch, {
handlers: [createPaymentHandler(wallet, mint, connection)],
});
const req = await fetchWithPayer(url);
Copy
import { createLocalWallet } from "@faremeter/wallet-evm";
import { createPaymentHandler } from "@faremeter/payment-evm/exact";
import { wrap as wrapFetch } from "@faremeter/fetch";
import { baseSepolia } from "viem/chains";
const wallet = await createLocalWallet(baseSepolia, privateKey);
const fetchWithPayer = wrapFetch(fetch, {
handlers: [createPaymentHandler(wallet)],
});
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
Agent Payments Protocol (AP2) by GoogleAn open protocol developed with leading payments and technology companies to securely initiate and transact agent-led payments across platforms.The protocol can be used as an extension of the Agent2Agent (A2A) protocol and Model Context Protocol (MCP). In concert with industry rules and standards, it establishes a payment-agnostic framework for users, merchants, and payments providers to transact with confidence across all types of payment methods.
Learn more about Google’s Agent Payments Protocol (AP2) here
Agentic Commerce Protocol (ACP) by Stripe, OpenAIAn open standard for programmatic commerce flows between buyers, AI agents, and businesses.ACP is open source and community-designed under the Apache 2.0 license. Businesses can implement the specification to transact with any AI agent or payment processor.With ACP, businesses maintain their customer relationships as the merchant of record, retaining control over which products can be sold, how they’re presented, and how orders are fulfilled.ACP supports flexible configurations for any commerce type, including physical and digital goods, subscriptions, and asynchronous purchases.
Learn more about Stripe and OpenAI’s Agentic Commerce Protocol here
Pay Per Crawl by CloudflareA feature of Cloudflare’s AI Crawl Control that enables site owners to control and monetize AI crawler access to content by setting a price per zone.Each time an AI crawler requests content, they either present payment intent via request headers for successful
HTTP 200 access, or receive an HTTP 402 Payment Required response with pricing. Cloudflare acts as the Merchant of Record for pay per crawl and also provides the underlying technical infrastructure.Learn more about Cloudflare’s Pay-to-Crawl protocol here