Refund Protocol for Agents

x402 Refund Protocol

A standard for open, transparent, and automated refund processing for x402. Built for developers, designed for openness.

Currently in alpha · APIs may change

Few lines to Enable Refunds

Pick your arbiter, deploy your escrow contract, mark routes as refundable, and let the protocol handle disputes. Minimal changes required.

Server Setup

TypeScript

import { refundable, withRefund } from '@x402r/extensions/refund';
...
app.use(paymentMiddleware(
  withRefund({
    'GET /api/data': {
      accepts: [
        refundable({
          scheme: 'exact',
          payTo: '0xmerchant123...',
          price: '$0.001',
          network: 'eip155:8453',
        }),
      ],
      description: 'API data endpoint',
    },
  }, FACTORY_ADDRESS),
));

Facilitator Hook

TypeScript

import { settleWithRefundHelper } from '@x402r/extensions/refund';
...
facilitator.onBeforeSettle(async (context) => {
  const { paymentPayload, paymentRequirements } = context;

  const result = await settleWithRefundHelper(
    paymentPayload,
    paymentRequirements,
    facilitator.signer
  );

  return result ? { abort: true } : null;
});

Ecosystem Partners

Building the future of refundable payments with innovative partners across the ecosystem.

x402 facilitators

What x402r Offers

The x402 refund protocol provides a standardized, secure, and customizable way to handle refunds for merchants.

Non-custodial

Funds can only go to the merchant or user, nowhere else. No third-party custody or risk

Open Source

All contracts are open source and auditable, ensuring complete transparency

Arbiter Agnostic

Choose your own arbiter or dispute resolver, maintaining control over the process

Minimal Changes

Very little changes to your current code are required to enable refund functionality

Transparent

On-chain verification and complete traceability of all transactions

Completely Free

No fees for users or merchants. Revenue comes from lending the escrow float in DeFi protocols