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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@phantom/client

v1.0.0

Published

HTTP client for Phantom Wallet API

Downloads

38,335

Readme

@phantom/client

HTTP client for Phantom Wallet API.

Installation

npm install @phantom/client
# or
yarn add @phantom/client

Usage

The PhantomClient class provides a fully typed HTTP client for interacting with Phantom's wallet service API.

Basic Usage (Without Authentication)

import { PhantomClient } from "@phantom/client";

const client = new PhantomClient({
  apiBaseUrl: "https://api.phantom.app/v1/wallets",
  organizationId: "your-org-id",
});

// Use the client for public endpoints
const wallets = await client.getWallets();

With Authentication (Using a Stamper)

The client accepts an optional stamper parameter that can be used to sign requests. You can use the @phantom/api-key-stamper package for API key authentication:

import { PhantomClient } from "@phantom/client";
import { ApiKeyStamper } from "@phantom/api-key-stamper";

// Create a stamper for authentication
const stamper = new ApiKeyStamper({
  apiSecretKey: "your-base58-encoded-secret-key",
});

// Create client with authentication
const client = new PhantomClient(
  {
    apiBaseUrl: "https://api.phantom.app/v1/wallets",
    organizationId: "your-org-id",
  },
  stamper,
);

// Now you can use authenticated endpoints
const wallet = await client.createWallet("My Wallet");

Available Methods

Wallet Management

  • createWallet(walletName?: string) - Create a new wallet with default addresses for Solana, Ethereum, Bitcoin, and Sui
  • getWallets(limit?, offset?) - List wallets for the organization with pagination support
  • getWalletAddresses(walletId, derivationPaths?) - Get addresses for a wallet, optionally specifying custom derivation paths

Transaction & Signing

  • signAndSendTransaction(params) - Sign and optionally submit a transaction to the blockchain
  • signMessage(params) - Sign a message with a wallet's private key
// Sign message
await client.signMessage({
  walletId: "wallet_123",
  message: "base64url_encoded_message",
  networkId: NetworkId.SOLANA_MAINNET,
});

// Sign transaction
await client.signAndSendTransaction({
  walletId: "wallet_123",
  transaction: "base64url_encoded_transaction",
  networkId: NetworkId.SOLANA_MAINNET,
});

Organization Management

  • getOrganization(organizationId) - Get organization details by ID
  • createOrganization(name, users) - Create a new organization with custom users
  • getWalletWithTag(params) - Get a wallet by tag from an organization
  • grantOrganizationAccess(params) - Grant access permissions to an organization

Authentication Management

  • createAuthenticator(params) - Create a new authenticator for a user in an organization
  • deleteAuthenticator(params) - Delete an authenticator from a user in an organization

Network Support

The client supports multiple blockchain networks through CAIP-2 identifiers. For a complete list of supported networks including Solana, Ethereum, Polygon, Base, Arbitrum, Monad, and more, see the Network Support section in the main README.

import { NetworkId } from "@phantom/client";

// Example: Solana
await client.signAndSendTransaction({
  walletId,
  transaction,
  networkId: NetworkId.SOLANA_MAINNET,
});

// Example: Ethereum
await client.signAndSendTransaction({
  walletId,
  transaction,
  networkId: NetworkId.ETHEREUM_MAINNET,
});

Custom Stamper Implementation

You can implement your own stamper for custom authentication methods:

class CustomStamper {
  async stamp(config: AxiosRequestConfig): Promise<AxiosRequestConfig> {
    // Add your custom authentication logic here
    config.headers = config.headers || {};
    config.headers["Authorization"] = "Bearer your-token";
    return config;
  }
}

const client = new PhantomClient(config, new CustomStamper());

Organization and Authentication Examples

// Get organization details
const organization = await client.getOrganization("org-id");

// Create organization with custom users
const newOrg = await client.createOrganization("My Organization", [
  {
    username: "admin-user",
    role: "ADMIN",
    authenticators: [
      {
        authenticatorName: "Primary Auth",
        authenticatorKind: "keypair",
        publicKey: "base64url-encoded-public-key",
        algorithm: "Ed25519",
      },
      {
        authenticatorName: "OIDC Auth",
        authenticatorKind: "oidc",
        jwksUrl: "https://issuer.com/.well-known/jwks.json",
        idTokenClaims: {
          sub: "user-subject-id",
          iss: "https://issuer.com",
        },
      },
    ],
  },
]);

// Get wallet by tag
const taggedWallet = await client.getWalletWithTag({
  organizationId: "org-id",
  tag: "demo-wallet",
  derivationPaths: ["m/44'/501'/0'/0'"],
});

// Create an authenticator for a user
const authenticator = await client.createAuthenticator({
  organizationId: "org-id",
  username: "user-123",
  authenticatorName: "New Auth",
  authenticator: {
    authenticatorName: "New Auth",
    authenticatorKind: "keypair",
    publicKey: "base64url-encoded-public-key",
    algorithm: "Ed25519",
  },
});

// Delete an authenticator
await client.deleteAuthenticator({
  organizationId: "org-id",
  username: "user-123",
  authenticatorId: "auth-id",
});

TypeScript Support

This package is written in TypeScript and provides full type definitions for all API methods and responses. All request parameter types are imported from @phantom/openapi-wallet-service.