Thesettlementlayerforthemachineeconomy.

Developers

Charge per request, not per checkout

Payment middleware and framework integrations

Drop-in x402 middleware for Express, Next.js, FastAPI and Spring Boot, gated on verified receipts.

Mount the middleware into your existing app in one call. A protected route answers HTTP 402 with a payment-required header, the caller returns a payment signature, and your handler releases its resource only after a sequencer-signed LayerX receipt verifies against the offer you issued. The middleware records each fulfillment under an idempotency key derived from the caller and the request digest, so a repeat returns the stored result instead of charging twice.

What it does

Four role packages (buyer, seller, merchant and agent) implement x402 version 2 over three HTTP headers, and framework adapters mount them into an existing app in one call. A protected route answers HTTP 402 with a PAYMENT-REQUIRED header, the caller returns a PAYMENT-SIGNATURE header, and the route releases its resource only after a sequencer-signed LayerX receipt verifies against the offer that was issued. Each fulfillment is recorded under an idempotency key derived from the caller principal and the request digest, so a repeated request returns the stored result instead of charging twice. A changed request under an existing key, or a receipt replayed from another request, is refused.

Key capabilities

  • Four role packages share one x402 version 2 wire contract: buyer, seller, merchant and agent.
  • One-call mounts: mountLayerX for Express and Next.js, mount_layerx for FastAPI, auto-configuration for Spring Boot.
  • Three offer schemes (exact, metered and subscription), each naming one registered asset id.
  • The agent package reserves, holds, commits or releases a budget around every spend.
  • Signed webhook consumer verifies Ed25519 deliveries, bounds their age and claims each delivery once.
  • A Next.js command fails the build when a declared secret reaches a browser bundle.

Who it's for

Developers charging per API call, and developers building agents that pay for calls.

Why it matters

A service can charge for a single request without a checkout page or an invoice: the payment travels in the request headers, and the handler runs only once a verified receipt binds the payer, payee, asset and amount to the offer. Existing Express, Next.js, FastAPI and Spring Boot routes keep their shape, and the middleware supplies the idempotency and replay rules rather than each service writing its own.

Differentiators

Release is gated on a verified receipt rather than an HTTP acknowledgement: the seller recomputes the receipt digest, resolves authority from configured trust, and refuses on any mismatch of payer, asset, recipient or amount. The same three payment signals encode over HTTP, MCP and A2A in the x402 interop adapter, and settlement identity is independent of which transport carried the request.

Outcomes

  • Charge for a single API call without a checkout page or invoice.
  • Keep your Express, Next.js, FastAPI or Spring Boot routes in their current shape.
  • Refuse replayed receipts and repeated charges without writing your own idempotency rules.

Technical notes

  • x402 version 2 only. Any other x402Version is refused. The adapter pins upstream spec revision 7d5363a6d51750dc246041f2b0ed5819dd46a0d7.
  • Payment headers are standard-base64 JSON bounded at 64 KiB; an offer set holds 1 to 32 entries; amounts are canonical decimal strings up to u128; asset and payTo are 32-byte hex.
  • Runtime floors: Node.js 22 or newer for the TypeScript packages, Python 3.11 or newer for FastAPI, Java 21 for the Spring Boot starter.
  • The middleware writes no balances. Seller issuance is edge translation, and settlement succeeds only against a gateway-verified canonical LayerX receipt.
  • The conformance package is private and non-authority; its vectors are local and do not attest interoperability with third-party implementations.
  • The Android and iOS packages carry session, receipt-gate and secret-scan source plus sample apps, not a framework mount; the iOS sample needs XcodeGen.
import express from "express";
import { mountLayerX, SingleProcessWebhookDeliveryStore } from "layerx-express";

const app = express();
mountLayerX(app, {
  environment: process.env,
  resources: { async release() { return { contentType: "application/json", body }; } },
  fulfillments: repository,
  deliveries: new SingleProcessWebhookDeliveryStore(),
  events: { async handle(event, deliveryId) { await record(deliveryId, event); } },
});
app.listen(8080);

More in Developers

Build on Paxeer.

Give your agent a wallet, set its policy, and settle your first call on LayerX.