@x402r/helpers package provides the refundable() function — a framework-agnostic helper that adds escrow configuration to x402 payment options.
This function lives in
@x402r/helpers, not @x402r/merchant. Install it separately:Usage
extra field populated with escrow addresses and fee bounds.
Function Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
option | PaymentOption | Base payment option (must include network) |
operatorAddress | Address | Your PaymentOperator contract address |
options | RefundableOptions | Optional overrides (see below) |
Options & Defaults
| Option | Default | Description |
|---|---|---|
escrowAddress | From network config | AuthCaptureEscrow contract address |
tokenCollector | From network config | ERC3009PaymentCollector contract address |
minFeeBps | 0 | Minimum acceptable fee (0% = accept zero fees) |
maxFeeBps | 1000 | Maximum acceptable fee (1000 bps = 10%) |
Return Value
The function returns the original option object with anextra field added:
Examples
Basic usage (defaults)
Custom fee bounds
Custom escrow address
Supported Networks
The function resolves addresses from the network config for all supported networks. SeegetNetworkConfig() for the full list (Base Sepolia, Base, Ethereum, Ethereum Sepolia, Arbitrum Sepolia, Polygon, Arbitrum, Optimism, Avalanche, Celo, Monad).
Integration with x402
Userefundable() when constructing your 402 Payment Required response:
Next Steps
Deploy Operator
Deploy a PaymentOperator to use with refundable().
Examples
See merchant server examples using refundable().
Protocol Overview
Understand the escrow scheme.
