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

v0.4.1

Published

Shared Accord rail-adapter interface + a Mock adapter for tests/demos. Rail-specific implementations (Ergo, Rosen, Base, x402) re-export the interface from here. See specs/ACCORD-006-rails.md.

Downloads

469

Readme

@accord-protocol/rails

Shared rail-adapter interface that @accord-protocol/mcp, @accord-protocol/gateway, and the rail-specific @accord-protocol/rails-{ergo,base,rosen,x402} packages all agree on.

A rail adapter has three responsibilities:

  1. verifyPayment(...) — confirm the buyer's payment proof is good and return a stable payment_id for replay protection.
  2. settle(...) (optional) — close out the economic side, return a Settlement Receipt.
  3. refund(...) (optional) — return funds when the engagement fails past the deadline.

Rail adapters are pure objects — no global state. The wrapping layer (gateway / MCP) supplies replay storage, agreement resolution, and receipt persistence. The rail's only job is to talk to its underlying payment system.

Install

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

Implementing a rail

import type { AccordRailAdapter } from "@accord-protocol/rails";

export const myRail: AccordRailAdapter = {
  rail: "ergo",
  async verifyPayment({ agreement, payment }) {
    const note = await checkNote(payment.note_box_id);
    if (note.value < BigInt(agreement.price.amount)) {
      return { ok: false, rail: "ergo", code: "INSUFFICIENT_VALUE", message: `note value ${note.value} < required ${agreement.price.amount}` };
    }
    return { ok: true, rail: "ergo", payment_id: note.box_id };
  },
  async settle({ agreement, payment }) {
    const tx = await redeemNote(payment.note_box_id);
    return { /* AccordSettlementReceipt with rail="ergo", mode="note_redeemed" */ } as never;
  },
};

Mock adapter for tests / demos

@accord-protocol/rails/mock ships a deterministic in-memory rail you can drop in anywhere a real rail is expected:

import { MockRailAdapter } from "@accord-protocol/rails/mock";

const rail = new MockRailAdapter();
// honest mode (default): accepts iff payment.value ≥ agreement.price.amount
// always_accept / always_reject / throw modes for failure-injection tests

The mock derives payment_id deterministically from the payment's canonical-JSON hash, emits valid Settlement Receipts that pass @accord-protocol/core's validateSettlementReceipt, and supports both settle and refund. Used in this repo's gateway / MCP test suites and conformance fixtures.

Per-rail conventions

| Rail | payment_id | Settlement mode | |---|---|---| | ergo | Note box id | note_redeemed / reserve_refunded / batch_settled | | rosen | Note box id (rsUSDT/rsUSDC/rsBTC) | same as ergo | | base | EVM tx hash | redeemed / refund_expired | | x402 | facilitator-issued payment proof id | paid_before_response |

These match the per-rail allow-list in @accord-protocol/core's RAIL_MODE_ALLOWLIST.

License

MIT.