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

@fluxpointstudios/orynq-sdk-payer-materios-x402

v0.1.1

Published

Materios-native sr25519 x402 payer + api-key passthrough for Materios billing gateway.

Readme

@fluxpointstudios/orynq-sdk-payer-materios-x402

Materios-native sr25519 x402 payer + api-key passthrough for the Materios billing gateway.

This package closes the client-side x402 loop for Materios billing. The gateway 402 middleware (services/blob-gateway/src/middleware/billing-402.ts) emits an X-402-Payment-Required header on requests that lack sufficient pallet-billing::Balances; this package generates the matching x-402-payment-signature + x-402-payer-ss58 headers the client returns on the retry.

Install

pnpm add @fluxpointstudios/orynq-sdk-payer-materios-x402

Quick start

Self-pay (sr25519)

The caller signs the canonical materios-x402 preimage with their own sr25519 key. The gateway debits pallet-billing::Balances for the SS58 that signed.

import {
  createMateriosPayer,
  parseMateriosPaymentRequired,
  unpackPaymentProofHeaders,
} from "@fluxpointstudios/orynq-sdk-payer-materios-x402";

const payer = createMateriosPayer({
  // mnemonic, raw `0x<64-hex>` seed, or `//Alice` dev derivation
  signerUri: process.env.MATERIOS_SIGNER_URI!,
});

// Original request returns 402:
const response = await fetch(url, originalOpts);
if (response.status === 402) {
  const payload = parseMateriosPaymentRequired(
    response.headers.get("X-402-Payment-Required")!,
  );
  const proof = await payer.pay({
    protocol: "x402",
    chain: "materios:preprod",
    asset: "MATRA",
    amountUnits: payload.pricing.amount,
    payTo: payload.recipient,
    raw: payload,
  });
  const headers = unpackPaymentProofHeaders(proof.signature);
  // Retry the original request with the headers attached:
  await fetch(url, {
    ...originalOpts,
    headers: { ...originalOpts.headers, ...headers },
  });
}

API-key (FPS-sponsored)

If you have an FPS-issued matra_… Bearer token, you don't sign — the api-key already authorizes the FPS treasury to sponsor your request. If the gateway still 402s while a valid api-key is attached, the treasury or your per-key cap is exhausted; pay() throws with an actionable message.

const payer = createMateriosPayer({ apiKey: process.env.MATRA_API_KEY! });
// Attach `Authorization: Bearer ${apiKey}` to your requests as usual.
// On 402, `payer.pay(...)` throws — surface the message to the user.

Wire-format contract

The canonical preimage signed by the self-pay path is v1 and matches the layout documented in src/preimage.ts and byte-pinned by src/__tests__/preimage.test.ts:

canonical_preimage = concat(
  utf8("materios-x402-v1"),               // 16-byte domain separator
  u32_le(len(endpointClass)) || utf8(endpointClass),
  u128_le(BigInt(pricing.amount)),
  bytes32(payload.nonce),                 // 32 raw bytes from "0x<64-hex>"
  u64_le(payload.expires)
)

The signed message is blake2_256(canonical_preimage). Verifiers MUST mirror this layout byte-for-byte; bumping the domain separator (e.g. materios-x402-v2) is the canonical way to roll the format without risk of cross-version replay.

Provenance

  • Phase 2.A part 4 of the prepaid-balance pipeline. Design ref: /home/deci/work/phase-2-prepaid-balance-design.md.
  • Pairs with:
    • pallet-billing (Materios runtime, PRs #19/#20/#21)
    • gateway 402 middleware (orynq-sdk PRs #43, #44)

License

MIT.