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

@x84-ai/x402

v0.1.2

Published

x402 payment middleware for x84 AI agents — Solana payments via x84 facilitator

Downloads

296

Readme

@x84-ai/x402

x402 payment middleware for x84 AI agents — Solana USDC payments via x84 facilitator with protocol fee split (3%).

Install

pnpm add @x84-ai/x402

Usage

Server — Express middleware (agent receives payments)

import express from "express";
import { x84PaymentGate } from "@x84-ai/x402/middleware";

const app = express();

// Payment config resolved from on-chain PaymentRequirement PDA
app.use(
  x84PaymentGate({
    agentMint: "YourAgentNftMintAddress",
    network: "devnet", // or "mainnet"
    rpcUrl: "https://api.devnet.solana.com",
    routes: {
      "POST /": { description: "Agent query" },
    },
  })
);

The agentMint is the agent's NFT mint address on Solana. The middleware derives the PaymentRequirement PDA from it and resolves payTo and price at runtime — the on-chain PDA is the single source of truth.

You can override the price per-route if needed:

routes: {
  "POST /": { price: "$0.001", description: "Agent query" },
  "POST /premium": { price: "$0.01", description: "Premium query" },
}

Client — paying for agent services

import { x402Client } from "@x402/core/client";
import { X84SvmScheme } from "@x84-ai/x402/client";

const scheme = new X84SvmScheme(walletAdapter);
const client = x402Client.register("solana:*", scheme);

const response = await client.fetch("https://agent.example.com/", {
  method: "POST",
  body: JSON.stringify({ message: "Hello" }),
});

The X84SvmScheme automatically splits payments: 97% to the agent operator, 3% protocol fee to x84 treasury.

Exports

| Entry point | Description | | ------------------------ | -------------------------------------------------- | | @x84-ai/x402 | Types, constants, AgentResolver | | @x84-ai/x402/middleware| x84PaymentGate Express middleware | | @x84-ai/x402/client | X84SvmScheme for client-side payment building |

Configuration

Environment variables

| Variable | Required | Description | | ---------------- | -------- | ------------------------------------- | | AGENT_MINT | Yes | Agent NFT mint address | | SOLANA_RPC_URL | No | Solana RPC endpoint (defaults by network) | | SOLANA_NETWORK | No | devnet or mainnet (default: devnet)|

X84PaymentGateConfig

| Field | Type | Required | Description | | ---------------- | -------- | -------- | ---------------------------------------------------------- | | agentMint | string | Yes | Agent NFT mint — derives PaymentRequirement PDA | | routes | object | Yes | Route → payment config map | | network | string | No | devnet, mainnet, or CAIP-2 string | | rpcUrl | string | No | Solana RPC URL (defaults based on network) | | facilitatorUrl | string | No | Custom facilitator (default: https://facilitator.x84.ai) | | treasury | string | No | Override protocol fee treasury | | protocolFeeBps | number | No | Override fee basis points (default: 300 = 3%) | | serviceType | string | No | PDA service type (default: a2a) |

How it works

Client                    Agent Server              x84 Facilitator        Solana
  │                           │                          │                   │
  ├── POST /agent ───────────>│                          │                   │
  │                           ├── 402 + paymentReqs ────>│                   │
  │<── 402 Payment Required ──┤                          │                   │
  │                           │                          │                   │
  │  Build split tx:          │                          │                   │
  │  97% → agent payTo        │                          │                   │
  │  3%  → x84 treasury       │                          │                   │
  │                           │                          │                   │
  ├── POST /agent + payment ─>│                          │                   │
  │                           ├── /settle ──────────────>│                   │
  │                           │                          ├── co-sign + submit ─> TX confirmed
  │                           │                          │                   │
  │                           │                          ├── record receipt ──> PaymentReceipt PDA
  │                           │                          │                   │
  │<── 200 + response ────────┤<── settlement OK ────────┤                   │

License

MIT