Server paywall
createPaywall from @4mica/sdk/server gates any route behind an x402 payment. When no valid X-PAYMENT header is present, the paywall returns a 402 with the payment requirements. Otherwise it verifies the payment and lets the request through, adding an X-PAYMENT-RESPONSE header.
The @4mica/sdk/server subpath is Buffer-free, so the paywall runs on edge runtimes as well as Node, Bun, and Deno.
The verifier can be
client.rpc, the client itself, or any object exposing an
issueGuarantee method (a bare GuaranteeVerifier).Configuration
PaywallConfig requires the advertised requirements and accepts several optional overrides.
Web-standard usage
paywall.handle(request) works with any Web Request/Response runtime, including Hono, Next.js route handlers, SvelteKit, Remix, Deno, and Bun.serve. It returns a Response on 402, or an object to merge onto your downstream response.
Low-level primitive
paywall.protect(input) is framework-agnostic. Pass the request method, url, and a case-insensitive header reader, and receive a decision.
The paywall only verifies payment. On-chain settlement stays out of band as
a recipient operation — see the cycle-clearing
claimNetCredit flow in
Client operations.Next steps
X402 flow
Sign payment headers on the client side.
Client operations
Deposit collateral, sign payments, and settle cleared cycles.