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

whop-x402

v1.0.0

Published

Whop x402 Payment Gateway Adapter for AI Agents

Readme

@whop-x402

An open-source, framework-agnostic x402-compatible adapter that allows Node.js/TypeScript-based AI agents to accept payments via Whop (subscriptions, memberships, digital goods) and automatically route native revenue into BNB Chain PancakeSwap on-chain buybacks.

Features

  • x402 protocol support: Emits challenge payloads compatible with the x402 agent-to-agent protocol.
  • On-chain routing: Executes native BNB swaps for utility tokens on PancakeSwap V2 (BSC).
  • Price Oracle: Automatic CoinGecko USD-to-BNB price tracking.
  • Webhook validation: Secure HMAC-SHA256 signature verification of Whop payments.
  • Event hooks: Typed Node EventEmitter callbacks for custom triggers.

Installation

npm install @whop-x402
# or
bun add @whop-x402

Quick Start (Express Webhook Example)

Here is how to set up the adapter with an Express server to monetize your AI agent:

import Express from 'express';
import WhopX402Adapter from '@whop-x402';

const app = Express();
app.use(Express.raw({ type: 'application/json' })); // raw body is required for HMAC validation

const adapter = new WhopX402Adapter(
  {
    apiKey: process.env.WHOP_API_KEY!,
    webhookSecret: process.env.WHOP_WEBHOOK_SECRET!,
  },
  {
    rpcUrl: process.env.BSC_RPC_URL || 'https://bsc-dataseed.binance.org/',
    chainId: 56, // 56 for Mainnet, 97 for Testnet
    walletPrivateKey: process.env.WALLET_PRIVATE_KEY!,
    tokenAddress: process.env.BUYBACK_TOKEN_ADDRESS!, // Target agent utility token
    buybackPercentage: 100, // Swap 100% of revenue to token
    slippagePercentage: 0.5,
  }
);

// Register Event Hooks
adapter.on('payment_received', (event) => {
  console.log(`💰 Payment of ${event.amountCents} cents received from ${event.payer}`);
});

adapter.on('buyback_executed', (event) => {
  console.log(`🔄 Buyback Executed: Swapped ${event.amountBNB} BNB. Tx Hash: ${event.txHash}`);
});

adapter.on('buyback_failed', (event) => {
  console.error(`❌ Buyback Failed: ${event.error}`);
});

// Webhook Ingestion Route
app.post('/whop-webhook', async (req, res) => {
  const signature = req.headers['x-whop-signature'] as string;
  if (!signature) {
    return res.status(400).send('Missing x-whop-signature header');
  }

  // Pass raw body string and header signature to the adapter
  const rawBody = req.body.toString('utf8');
  const result = await adapter.handlePaymentWebhook(rawBody, signature);

  if (!result.success) {
    return res.status(400).json(result);
  }

  return res.json(result);
});

app.listen(3000, () => console.log('Agent payment gateway active on port 3000'));

Fetch.ai & Agentverse

The adapter is framework-agnostic, so it plugs into any Fetch.ai agent stack. Because the ASI:One Chat Protocol and uAgents run in Python, the recommended topology for a Node.js agent is:

  • TypeScript webhook service (examples/agentverse-webhook-agent.ts) — an Express server exposing GET /status, GET /checkout (returns the Whop checkout / x402 payment challenge), POST /whop-webhook (HMAC-verified, triggers the PancakeSwap buyback), and GET /proof (latest on-chain tx hash). Deploy it and expose it with a tunnel (cloudflared tunnel --url http://localhost:8080).
  • Python chat agent (../python/examples/agentverse_chat_agent.py) — an ASI:One Chat Protocol uAgent that hands buyers the checkout link and surfaces the buyback proof.

Veridex Agent Fabric Integration

We also provide a fully-equipped, production-grade example using our core framework @veridex/agents:

  • Veridex Chat Agent (examples/veridex-chat-agent.ts) — A conversational AI agent constructed with the declarative createAgent factory. It wraps the payment adapter inside a safe, typed Tool (create_checkout_link) and implements on-chain proof retrieval (get_latest_buyback_proof) out of the box!

To run the Veridex Chat Agent:

bun run examples/veridex-chat-agent.ts

To run the standalone Webhook agent:

bun run examples/agentverse-webhook-agent.ts

License

MIT License.