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

moltydex

v1.1.0

Published

MoltyDEX SDK — x402 auto-pay agent and API client for Solana token swaps. Pluggable wallet architecture supports local keys, MPC, and custom signers.

Downloads

513

Readme

MoltyDEX SDK

x402 auto-pay agent and API client for Solana token swaps. Zero fees, best prices via Jupiter.

npm License: MIT

Features

  • Automatic 402 Handling — Intercepts and processes x402 payment requirements
  • Token Swapping — Automatically swaps to required tokens via Jupiter aggregator
  • Pluggable Wallet Architecture — Bring your own signer: local keys, MPC wallets, hardware wallets, or custodial
  • HTTP Interceptor — Drop-in fetch wrapper that handles payments transparently
  • TypeScript — Fully typed with exported TransactionSigner interface

Installation

npm install moltydex

Quick Start

Option 1: Local Wallet (simplest)

import { HTTPInterceptor } from 'moltydex';

const interceptor = new HTTPInterceptor({
  apiUrl: 'https://api.moltydex.com',
  walletPath: '~/.config/solana/id.json',
  autoSwap: true,
});

// All fetch calls now handle 402 responses automatically
const response = await fetch('https://premium-api.com/data');

Option 2: Bring Your Own Signer (MPC, hardware, custodial)

import { X402AutoPayAgent, TransactionSigner } from 'moltydex';

// Implement the TransactionSigner interface with any wallet backend
const mySigner: TransactionSigner = {
  getAddress: () => '7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU',
  signTransaction: async (txBase64: string) => {
    // Sign with your MPC provider, hardware wallet, etc.
    return signedTxBase64;
  },
};

const agent = new X402AutoPayAgent({
  apiUrl: 'https://api.moltydex.com',
  signer: mySigner,
});

const result = await agent.handle402(paymentResponse);

TransactionSigner Interface

The TransactionSigner interface is the core abstraction that makes MoltyDEX wallet-agnostic. Any wallet backend can implement it:

interface TransactionSigner {
  /** Returns the wallet's public key as a base58 string. */
  getAddress(): string;

  /** Signs a base64-encoded Solana transaction, returns signed base64. */
  signTransaction(transactionBase64: string): Promise<string>;

  /** Optional: builds a payment transaction (SOL or SPL token). */
  buildPaymentTransaction?(
    recipientAddress: string,
    tokenMint: string,
    amount: string,
  ): Promise<string>;
}

Built-in implementations:

  • WalletManager — loads a local Solana keypair from file or secret key

You can implement it for:

  • Turnkey MPC wallets
  • Crossmint custodial wallets
  • Privy embedded wallets
  • Lit Protocol distributed keys
  • Hardware wallets (Ledger)
  • Any custom signing logic

Configuration

interface AgentConfig {
  apiUrl: string;                   // MoltyDEX API URL

  // Option A: Provide a TransactionSigner (for custom/MPC wallets)
  signer?: TransactionSigner;

  // Option B: Let WalletManager create one (backwards-compatible)
  walletPath?: string;              // Path to wallet JSON file
  walletSecretKey?: Uint8Array | number[] | string;
  walletAddress?: string;           // Optional: for verification

  preferredInputToken?: string;     // Token to swap from (default: SOL)
  autoSwap?: boolean;               // Auto-execute swaps (default: true)
  webhookUrl?: string;              // Optional webhook for status updates
  rpcUrl?: string;                  // Optional: override Solana RPC URL
  maxRetries?: number;              // Max retry attempts (default: 3)
  retryDelay?: number;              // Delay between retries in ms (default: 2000)
}

How It Works

1. Agent makes API call
   ↓
2. API returns 402 Payment Required
   ↓
3. Auto-Pay Agent intercepts
   ↓
4. Parse payment requirements
   ↓
5. Check balance
   ↓
6. Swap tokens if needed (via Jupiter)
   ↓
7. Sign payment with TransactionSigner
   ↓
8. Wait for confirmation
   ↓
9. Retry original request
   ↓
10. Success!

API Reference

Classes

| Class | Description | |-------|-------------| | X402AutoPayAgent | Main agent — accepts AgentConfig with either signer or key material | | HTTPInterceptor | Drop-in fetch wrapper that auto-handles 402 responses | | MoltyDEXClient | Low-level API client for quotes, swaps, balances | | WalletManager | Built-in TransactionSigner implementation using local Solana keypairs |

Types

| Type | Description | |------|-------------| | TransactionSigner | Interface for pluggable wallet backends | | AgentConfig | Configuration for agent/interceptor | | PaymentRequirement | Parsed 402 payment requirement | | AutoPayResult | Result of a payment attempt |

Python SDK

Also available on PyPI:

pip install moltydex

See pypi.org/project/moltydex for Python documentation.

License

MIT — see LICENSE

Links