middlebit

x402 payment middleware for stablecoin content gating on Base and Radius.

loading...

Middlebit normalizes USDC (EIP-3009) and SBC (EIP-2612) payments into a consistent API across Base and Radius networks. Point your frontend at middlebit with your merchant wallet address — everything else (facilitator setup, signature standards, on-chain settlement) is handled for you.

What You Need

  1. Middlebit URL:
  2. Your merchant wallet address (where you receive funds)

That's it. No API keys, no extra accounts, no backend configuration.

Value Types & Transfer Types

A value type is the form of value (SBC, USDC). A transfer type is the mechanism it moves on (Base, Radius). Learn more →

Value TypeTransfer TypeStandardDecimalsAddress
USDC Base (8453) EIP-3009 6 0x833589fC...02913
SBC Base (8453) EIP-2612 18 0xfdcC3dd6...80798
SBC Radius (723) EIP-2612 6 0x33ad9e4b...14fb

The user pays zero gas — middlebit settles on-chain. USDC uses the thirdweb facilitator; SBC uses the stablecoin.xyz facilitator.

API Endpoints

GET /api/health

Health check. Returns version, supported value types, and transfer types.

GET /api/value-types

Value type and transfer type configs for client discovery.

POST /api/payment-requirements

Returns 402 with x402 v1 payment requirements. The frontend uses these to construct the EIP-712 signing request.

Note: You pass your merchant wallet as payTo. The response returns the on-chain addresses middlebit uses internally — your client just needs to sign what's returned.

POST /api/settle

Settles a signed payment on-chain. The paymentSignature is a base64-encoded x402 v1 payload.

Funds Flow

Dashed lines are data/instructions. Solid lines are value transfers. Follows the Commons Stablecoin Format.

CSF v1.4.5 · Medium
sequenceDiagram
    participant User as End User Wallet
    participant App as Frontend / App
    participant Middlebit as middlebit
    participant Chain as Blockchain
    participant Merchant as Merchant Wallet

    User-->>App: [DATA] Request gated content
    App-->>Middlebit: [DATA] POST /api/payment-requirements
    Middlebit-->>App: [DATA] 402 Payment Required
    App-->>User: [DATA] EIP-712 signing request
    User-->>App: [DATA] Signed payload
    App-->>Middlebit: [DATA] POST /api/settle (signed payload)
    Middlebit->>Chain: Submit transfer
    Chain->>Merchant: Confirm Receipt
    Middlebit-->>App: [DATA] Transaction receipt
    App-->>User: [DATA] Content unlocked
      

The end user pays zero gas. When a user pays, they sign a transfer to a settlement wallet. Middlebit submits it for on-chain execution, and funds are forwarded to your merchant wallet. You provide your merchant wallet address, token, network, amount, and resource URL.

Integration Prompt

Copy this and hand it to an AI coding agent or use it as a spec to build a client:


    

Changelog

v1.5.1 2026-03-08
  • Fixed ERC-2612 payload translation for stablecoin.xyz facilitator (field name remapping)
  • Verified real SBC settlement on Base mainnet end-to-end
  • Corrected API docs, integration prompt, and test harness error detection
v1.5.0 2026-03-08
  • Adopted Value Layer vernacular: value types (USDC, SBC) and transfer types (Base, Radius)
  • Added Radius transfer type (chain ID 723) for SBC
  • Switched SBC settlement to stablecoin.xyz facilitator (x402 v2)
  • New endpoint /api/value-types replaces /api/supported-tokens
  • API params renamed: valueType + transferType replace token + network
  • Added end-to-end test harness for browser-based payment flow testing
  • Expanded smoke test suite to 10 tests
v1.4.0 2026-02-15
  • Initial SBC (EIP-2612) support on Base via thirdweb facilitator
  • Added /api/supported-tokens endpoint for client discovery
  • CORS support with configurable allowed origins
v1.3.0 2026-01-20
  • USDC (EIP-3009) payment flow on Base mainnet
  • x402 v1 payment requirements and settlement endpoints
  • Integration prompt for AI-assisted client generation

Tools

Source

Middlebit is open source. The codebase is ~500 lines of TypeScript across 4 API endpoints and 3 utility modules.