Skip to main content

Quick Start for Merchants

1. Deploy Your Escrow Contract

Contact your escrow service provider or use our escrow factory contract at x402r-contracts.

There will be a 1:1 mapping for easy lookups: escrow contract address ↔ merchant payout address

2. Install the Package

npm install @x402/extensions

3. Mark Routes as Refundable

import { refundable, withRefund } from '@x402/extensions/refund'

const routeConfig = {
accepts: refundable({
scheme: 'exact',
payTo: MERCHANT_PAYOUT,
price: '$0.001',
network: 'eip155:84532',
}),
}

const processed = withRefund(routeConfig, DEPOSIT_RELAY_ADDRESS)

What Happens Under the Hood

  1. refundable() stores your original merchant payout address in extra._x402_refund_merchantPayout
  2. withRefund() processes the route config and:
    • Sets payTo to the DepositRelay address for all refundable options
    • Preserves the original merchant address in the extra field

That's it! Payments to this route now go through escrow.