Skip to main content
The SDK includes 7 working examples in the x402r-sdk/examples/ directory. Each example is a standalone project that demonstrates a specific integration pattern.

Available Examples

deploy-operator

Deploy a complete marketplace operator with escrow, freeze, and arbiter support.Key concepts: deployMarketplaceOperator(), factory pattern, CREATE2

merchant-server

HTTP server that accepts escrow payments and handles refunds.Key concepts: refundable(), payment verification, release flow

merchant-cli

CLI tool for merchants to release payments, approve/deny refunds, and query state.Key concepts: X402rMerchant, release(), approveRefundRequest()

client-cli

CLI tool for payers to request refunds, freeze payments, and check status.Key concepts: X402rClient, requestRefund(), freezePayment()

arbiter-cli

CLI tool for arbiters to review cases, make decisions, and manage registry.Key concepts: X402rArbiter, approveRefundRequest(), registerArbiter()

e2e-dispute

End-to-end dispute resolution flow: deploy operator, create payment, freeze, request refund, arbiter resolves.Key concepts: Full lifecycle, createFacilitatorSigner(), getPaymentInfoFromEvents()

shared

Shared utilities used by the CLI examples (display helpers, PaymentInfo formatting).

Running Examples

Each example is a standalone project. To run one:
cd x402r-sdk/examples/<example-name>

# Install dependencies
pnpm install

# Set environment variables
export PRIVATE_KEY=0x...
export RPC_URL=https://sepolia.base.org

# Run
pnpm start
All examples require a private key with Base Sepolia ETH and USDC. Get testnet USDC from the Base Sepolia Faucet.

deploy-operator

Deploys a complete marketplace operator using deployMarketplaceOperator():
import { deployMarketplaceOperator } from '@x402r/core/deploy';

const result = await deployMarketplaceOperator(
  walletClient,
  publicClient,
  'eip155:84532',
  {
    feeRecipient: account.address,
    arbiter: arbiterAddress,
    escrowPeriodSeconds: 604800n, // 7 days
    operatorFeeBps: 100n,         // 1%
  }
);
See Deploy an Operator for the full guide.

e2e-dispute

The most comprehensive example — runs through the entire dispute lifecycle:
  1. Deploys a fresh operator
  2. Creates a payment with ERC-3009 authorization
  3. Payer freezes the payment
  4. Payer requests a refund
  5. Arbiter reviews and approves
  6. Arbiter executes the refund
This example uses createFacilitatorSigner() from @x402r/evm and getPaymentInfoFromEvents() from @x402r/arbiter to reconstruct PaymentInfo from on-chain events.

merchant-server

Demonstrates a minimal HTTP server that:
  1. Returns 402 with refundable() payment options
  2. Verifies incoming payments via the facilitator
  3. Watches for refund requests
  4. Auto-approves or requires manual review

Next Steps