Payment Infrastructure for Web3

xRail enables seamless, secure blockchain payments with minimal friction. Build the future of decentralized commerce with our facilitator infrastructure powered by x402 protocol. SDK integration allows automatic credit refills when interacting with the facilitator.

XRail Facilitator - X-402 Paid Service

The XRail facilitator on Base Sepolia is a paid service supporting the X-402 protocol. It uses a credit-based system where credits are purchased with USDC and automatically deducted when the facilitator settles your payments.

Note: This is a testnet deployment on Base Sepolia for testing and demonstration purposes. The fees shown here are for testing only. Mainnet deployment will have significantly lower fees.

🎫 How It Works

1. Acquire Credits

Send USDC to the facilitator contract. You'll be credited the full USDC amount, minus the facilitator fee.

2. Make Payments

When you submit a payment through the facilitator, your credit balance is checked to ensure you have sufficient credits.

3. Automatic Deduction

The facilitator executes your USDC transfer on-chain and automatically deducts the fee per transaction from your credits.

🔐 Smart Contract

The XRailFacilitator contract (proxy) is deployed on Base Sepolia at:

0xb5fcF9c691E0043c71692b5aEc8352b541BbC65F View on BaseScan ↗

Technical Details: The contract uses EIP-3009 for gasless USDC payments and implements an upgradeable proxy pattern (ERC-1967) for future improvements. Credits use 6 decimals (same as USDC). All balances are verifiable on-chain and tied to your wallet address.

✨ Benefits

  • Automatic Credit Management: SDK integration enables automatic credit refills when 402 responses are received
  • Gasless Transfers: Uses EIP-3009 to enable USDC transfers without gas fees
  • Predictable Pricing: Simple and transparent fee structure per transaction
  • Verifiable On-Chain: All credit balances and transactions are transparent on Base Sepolia
  • Secure & Upgradeable: Built with security best practices and future-proof design

Getting Started

TypeScript
// Install the PayRail SDK
npm install @payrail/sdk-nodejs

// Integrate with facilitator - automatic credit refill on 402
import axios from 'axios';
import { PayRailClient } from '@payrail/sdk-nodejs';

// Initialize client with your private key
const payrailClient = new PayRailClient({
  privateKey: process.env.PRIVATE_KEY!,
  debug: true
});

// Create axios instance for facilitator API
const facilitatorApi = axios.create({
  baseURL: 'https://facilitator.xrail.io'
});

// Attach interceptor - automatically handles 402 & refills credits
payrailClient.attachInterceptor(facilitatorApi);

// Make requests - 402 handled automatically with credit refill!
// Example: Buy credits from facilitator
const response = await facilitatorApi.post('/credits/purchase', {
  amount: '1000000',
  network: 'base-sepolia'
});

Quick Start Guide

  1. Install SDK

    Add @payrail/sdk-nodejs to your project with npm

  2. Configure PayRailClient

    Initialize with your private key for making payments to facilitator

  3. Attach Interceptor

    Connect SDK to your facilitator axios instance

  4. Make Requests

    SDK automatically handles 402 responses and refills credits as needed

Technical Documentation