middlebit

x402 payment middleware for stablecoin content gating on Base.

loading...

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

Your Frontend → middlebit → Base mainnet

What You Need

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

That's it. No API keys, no thirdweb accounts, no facilitator configuration.

Supported Tokens

TokenStandardDecimalsAddress
USDC EIP-3009 6 0x833589fC...02913
SBC EIP-2612 18 0xfdcC3dd6...80798

Both on Base (chain ID 8453). The user pays zero gas — thirdweb settles on-chain.

API Endpoints

GET /api/health

Health check. Returns version and supported tokens.

GET /api/supported-tokens

Token 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 via thirdweb. The paymentSignature is a base64-encoded x402 v1 payload.

Payment Flow

  1. Connect wallet to Base (chain ID 8453)
  2. POST /api/payment-requirements — get signing instructions
  3. User signs EIP-712 typed data in wallet (no gas, no transaction)
  4. Encode payload: btoa(JSON.stringify({ x402Version: 1, payload: { signature, authorization } }))
  5. POST /api/settle with paymentSignature — get transaction receipt
  6. Unlock content

Integration Prompt

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


    

How Funds Flow

When a user pays, the signed transfer goes to an intermediary wallet managed by middlebit. Settlement happens on-chain and funds are forwarded to your merchant wallet. The end user pays zero gas.

You provideMiddlebit handles
Your merchant wallet addressFacilitator wallet, on-chain settlement, gas fees
Token choice + amountEIP-712 signing instructions, payload normalization
Resource URL (gated content)Payment verification + transaction receipt

Source

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