> ## 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.

# Fetch 参数

> wrapFetchWithPayment 的输入参数说明

## 签名

```ts theme={null}
wrapFetchWithPayment(
  fetch: typeof globalThis.fetch,
  walletClient: WalletClient,
  maxValue?: string,
  paymentRequirementsSelector?: (r402: Response402) => PaymentRequirements
): typeof globalThis.fetch
```

## 说明

* `maxValue`：最大允许支付额（强烈建议设置）
* `paymentRequirementsSelector`：自定义选择 requirements

## 完整签名与类型

```ts theme={null}
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;
```

> 提示：`maxValue` 默认值应谨慎评估；生产环境建议显式设置以防止异常高额支付。
