Documentation Index
Fetch the complete documentation index at: https://docs.x402x.ai/llms.txt
Use this file to discover all available pages before exploring further.
Signature
wrapFetchWithPayment(
fetch: typeof globalThis.fetch,
walletClient: WalletClient,
maxValue?: string,
paymentRequirementsSelector?: (r402: Response402) => PaymentRequirements
): typeof globalThis.fetch
Notes
maxValue: the maximum allowed payable amount (strongly recommended)
paymentRequirementsSelector: custom selector for requirements
Full signature and types
import type { WalletClient } from "viem";
type PaymentRequirementsSelector = (
requirements: PaymentRequirements[],
network?: string[],
scheme?: string
) => PaymentRequirements;
interface X402Config {
svmConfig?: {
rpcUrl?: string;
};
evmConfig?: {
rpcUrls?: Record<number, string>;
};
}
wrapFetchWithPayment(
fetch: typeof globalThis.fetch,
walletClient: WalletClient,
maxValue?: bigint,
paymentRequirementsSelector?: PaymentRequirementsSelector,
config?: X402Config
): typeof globalThis.fetch;
Tip: choose a conservative default for maxValue; in production, set it explicitly to prevent excessive payments.