npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@accord-protocol/rails-x402

v0.4.1

Published

Accord rail adapter for x402-compatible HTTP payments. Wraps any x402 facilitator (Coinbase, custom) into the AccordRailAdapter shape so x402 endpoints can settle Accord agreements atomically (pay_before_response).

Readme

@accord-protocol/rails-x402

Accord rail adapter for x402-compatible HTTP payments. Wraps any x402 facilitator (Coinbase's hosted one, a self-hosted shim, or a test stub) into the AccordRailAdapter shape.

This is the rail that lets x402 endpoints upgrade into Accord agreements — keep paying USDC on Base via x402, get verifiable Accord work-receipts on top.

Install

npm install @accord-protocol/rails-x402 @accord-protocol/rails @accord-protocol/core

No other dependencies — the facilitator is pluggable, you wire whichever HTTP client (or stub) you want.

Usage

import { createX402RailAdapter, type X402Facilitator } from "@accord-protocol/rails-x402";

const facilitator: X402Facilitator = {
  network: "base-sepolia",
  async verify({ agreement, paymentPayload, scheme }) {
    const r = await fetch("https://x402.coinbase.com/verify", {
      method: "POST",
      body: JSON.stringify({ /* per facilitator API */ }),
    });
    const json = await r.json();
    return json.ok
      ? { ok: true, payment_id: json.payment_id, scheme: json.scheme, payer: json.payer }
      : { ok: false, code: json.code, message: json.message };
  },
  async settle({ agreement, paymentPayload, payment_id }) {
    const r = await fetch("https://x402.coinbase.com/settle", { /* … */ });
    const json = await r.json();
    return { tx_hash: json.tx_hash, block_height: json.block_height };
  },
};

const rail = createX402RailAdapter({ facilitator });

How x402 maps to Accord

Per ACCORD-003, the x402 rail's only mode is paid_before_response — payment is verified atomically, the response goes back, the buyer either got the work or didn't pay.

Receipt shape:

{
  "type": "accord.settlement_receipt.v0",
  "rail": "x402",
  "mode": "paid_before_response",
  "status": "settled",
  "tx": { "tx_id": "<facilitator-issued payment_id>", "network": "base-sepolia", "block_height": ... }
}

payment_id (from the facilitator) doubles as the receipt's tx_id when the facilitator doesn't expose a separate settle endpoint — typical for facilitator-broker setups where verify and submit happen in one round-trip.

Buyer payment-proof shape

{
  "x402_payment_payload": "<base64 of facilitator's PaymentPayload>",
  "scheme": "exact"
}

The payload is opaque — for Coinbase's facilitator on Base it's an EIP-3009 transferWithAuthorization signature. The adapter doesn't decode it; it hands it to the facilitator.

verifyPayment checks (in order)

  1. Shapex402_payment_payload is a non-empty string.
  2. Currency — agreement asks for USDC or USDT (rejection: CURRENCY_NOT_SUPPORTED; for ERG use rails-ergo, for rsUSDT/rsUSDC/rsBTC use rails-rosen, for native ERC-20 paywalled-Note flows use rails-base).
  3. facilitator.verify(...) — the rail of last resort. Returns ok + payment_id or a structured rejection.
    • On ok: falseFACILITATOR_REJECTED.
    • On thrown → FACILITATOR_UNAVAILABLE.

On success: payment_id is whatever the facilitator returns (typically the EVM tx hash that will land the payment).

settle behaviour

settle() re-calls facilitator.verify(...) (idempotent under x402's stateless contract) to get a fresh payment_id, then optionally calls facilitator.settle(...) for the real on-chain tx_hash. If the facilitator doesn't expose settle, the adapter still returns a settled Settlement Receipt using payment_id as the tx id — typical for facilitator-flow x402 where verify and submit happen in the same step.

Error codes

X402_RAIL_ERROR_CODES:

INVALID_PAYMENT_SHAPE
FACILITATOR_REJECTED
FACILITATOR_UNAVAILABLE
CURRENCY_NOT_SUPPORTED

Why this exists

x402 verifies payment. Accord verifies completion.

x402 alone gives you a paid request; Accord adds the agreement object, the verifier hook, the dispute trail, and the cross-rail settlement registry. The rails-x402 adapter is the bridge: existing x402 providers can join Accord without changing payment rails. Set price + verification rules in an Accord Agreement, accept the same x402 X-PAYMENT header, return Accord Verification + Settlement Receipts on top.

License

MIT.