The micropayment revolution is underway.

Crosshatch is an Effect toolkit for requiring and accepting payment through x402.

No accounts, no API keys, no separate billing system.

$ pnpm add crosshatch
1
Client

Requests a resourceOrdinary HTTP — no account, no payment yet

2
Merchant

Returns payment termsHTTP 402 Payment Required

3
Client

Retries with signed paymentSame request, payment payload attached

4
Merchant

Verifies, settles, and servesPayment checks out → resource body

Don’t build a billing system

Before Crosshatch
  • Customer records for access
  • API keys as prepaid identity
  • Plans, seats, and free-tier walls
  • Usage meters and overage rules
  • Invoices, credits, and top-ups
  • Webhooks reconciling paid vs delivered
After Crosshatch
  • Price the route not a plan tier
  • Charge the request not a customer record
  • Clients pay mid-call from a wallet no human signup or keys
  • Settle and serve no portal, no reconciling

Both sides of the call, in Effect

Same protocol whether you’re buying or selling: pay as a client layer, charge as route logic.

Client

Pay as a client

Wire a payer into your Effect client. On 402, Crosshatch pays and retries automatically — your program stays an ordinary Effect workflow.

Merchant

Require payment

Declare a price on the route. Crosshatch returns 402 until paid, settles, then serves — no separate billing product for the charge itself.

Install is above. Pick a path.

Two short guides — client auto-pay and merchant require-and-settle.

As a client

Pay for x402 resources from Effect programs — auto-pay on 402, retry, continue.

Client quickstart

As a merchant

Add payments to your routes — declare price, settle, serve with minimal code.

Merchant quickstart

Client and merchant shapes

Highlighted lines are Crosshatch. Payment handling sits in a layer so business logic stays ordinary Effect. The client sample hits one public x402 endpoint; the same composition works for any paid HTTP resource.

Client

Pay from an Effect client

Payment disappears into the layer. On 402, pay and retry inside the same Effect program.

Full client quickstart →
client.ts pay on 402
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai-compat"
import { Http402 } from "crosshatch"
import { Effect, Layer } from "effect"
import { LanguageModel } from "effect/unstable/ai"
// PayerLive: wallet + facilitator client (see quickstart)
// import { PayerLive } from "./payer"

// Any x402 HTTP resource — this endpoint is one public example
const PaidApiLive = OpenAiLanguageModel.layer({
  model: "deepseek/deepseek-chat",
}).pipe(
  Layer.provide(OpenAiClient.layer({
    apiUrl: "https://blockrun.ai/api/v1",
  })),
)

LanguageModel.generateText({
  prompt: "Hello from Crosshatch.",
}).pipe(
  Effect.provide(PaidApiLive.pipe(
    Layer.provide(Http402.layerClient.pipe(
      Layer.provide(PayerLive),
    )),
  )),
  Effect.runFork,
)