X-PAYMENT headers from clients, and retries settlement before allowing requests to proceed.
Prerequisites
- Node.js and npm installed
- A SKALE Chain endpoint
- Understanding of x402 protocol
- Express or Hono framework
- A facilitator service (see Running a Facilitator)
Overview
To become an x402 merchant, you need to:- Set up a facilitator service
- Install x402 middleware
- Protect your HTTP endpoints
- Define payment requirements
Quick Start (Express)
/premium, the middleware:
- Calls the facilitator’s
/acceptsendpoint to produce canonical requirements - Returns a
402 Payment Requiredresponse (with the facilitator payload) if the incoming request lacks a validX-PAYMENTheader - When a header is present, forwards it to
/settle. If settlement succeeds, the request pipeline continues; otherwise another 402 is returned
Quick Start (Hono)
API Surface
Express Adapter
Hono Adapter
Multiple Payment Options
Provide an array of arrays inaccepts to describe alternative requirement sets:
Resource-Specific Requirements
Leaveresource undefined in the accepts entries to let the middleware fill it with the current request URL:
