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

@x402-agent-gateway/client

v1.0.3

Published

Frontend SDK for x402-native agent and tool orchestration

Readme

@x402-agent-gateway/client

Frontend SDK for x402-native agent and tool orchestration. This package provides a client-side interface for interacting with x402 payment-enabled tool servers and chat completions.

For the server SDK, see @x402-agent-gateway/server.

Installation

npm install @x402-agent-gateway/client @solana/web3.js

Configuration

The client requires a configuration object with the following options:

interface ClientConfig {
  baseURL: string;        // Base URL of the x402 tool server
  wallet: any;            // Solana wallet adapter or Keypair
  network: Network;       // "solana" | "solana-devnet"
  rpcUrl?: string;       // Optional custom RPC URL
}

Configuration Options

  • baseURL (required): The base URL of your x402 tool server (e.g., "http://localhost:3000" or "https://api.example.com")
  • wallet (required): A Solana wallet adapter (from @solana/wallet-adapter-react) or a Keypair from @solana/web3.js
  • network (required): The Solana network to use. Must be either "solana" (mainnet) or "solana-devnet" (devnet)
  • rpcUrl (optional): Custom Solana RPC endpoint. If not provided, defaults to a public RPC endpoint

Usage

Basic Setup

import { createClient } from '@x402-agent-gateway/client';
import { Keypair } from '@solana/web3.js';

// Using a Keypair
const wallet = Keypair.fromSecretKey(yourSecretKey);

const client = createClient({
  baseURL: 'http://localhost:3000',
  wallet,
  network: 'solana-devnet',
});

With Wallet Adapter (React)

import { createClient } from '@x402-agent-gateway/client';
import { useWallet } from '@solana/wallet-adapter-react';

function MyComponent() {
  const { wallet, publicKey } = useWallet();
  
  const client = useMemo(() => {
    if (!wallet?.adapter || !publicKey) return null;
    
    return createClient({
      baseURL: 'http://localhost:3000',
      wallet: wallet.adapter,
      network: 'solana-devnet',
      rpcUrl: 'https://api.mainnet-beta.solana.com',
    });
  }, [wallet, publicKey]);
  
  // Use client...
}

API Reference

Tools API

To make use of tools here you must first register them in your API using the server SDK.

List Available Tools

const tools = await client.tools.list();
// Returns: ToolMetadata[]

Invoke a Tool

const result = await client.tools.invoke('tool-name', {
  arg1: 'value1',
  arg2: 123,
});
// Automatically handles payment if required

Chat API

Create Chat Completion

const response = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'user', content: 'Hello!' }
  ],
  tools: 'auto', // Automatically includes available tools defined with the server SDK
});
// Automatically handles payment if required

The chat completion API follows the OpenAI Chat Completions format and automatically includes available tools from the server.