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

pumpdotfun-sdk-v3.0

v3.1.3

Published

A simple SDK for interacting with pumpdotfun

Readme

PumpFun SDK v3.0

npm version License: MIT

A TypeScript SDK for interacting with the Pump.fun decentralized application on Solana. This SDK provides a simple interface for creating, buying, and selling tokens through the Pump.fun protocol.

Features

  • 🚀 Token Creation: Create new tokens with custom metadata
  • 💰 Trading Operations: Buy and sell tokens with built-in slippage protection
  • 📊 Real-time Events: Listen to token creation, trade, and completion events
  • 🔧 Instruction Generation: Generate raw instructions for custom transaction building
  • 🛡️ Type Safety: Full TypeScript support with comprehensive type definitions
  • Performance: Built with modern TypeScript and optimized for speed

Installation

npm install pumpdotfun-sdk-v3.0

Example Implementation

https://github.com/pumpsol03-ui/pumpdotfun-example

API Reference

Core Methods

| Method | Description | Returns | |--------|-------------|---------| | createAndBuy() | Create token and buy in one transaction | Promise<TransactionResult> | | buy() | Buy existing token | Promise<TransactionResult> | | sell() | Sell token | Promise<TransactionResult> | | getGlobalAccount() | Get global program state | Promise<GlobalAccount> | | getBondingCurveAccount() | Get token bonding curve data | Promise<BondingCurveAccount> |

Prerequisites

  • Node.js >= 20.9.0
  • A Solana RPC endpoint (recommended: Helius)
  • SOL tokens for transaction fees and trading

Quick Start

1. Environment Setup

Create a .env file in your project root:

HELIUS_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY

2. Basic Setup

import { Connection, Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import { PumpFunSDK } from "pumpdotfun-sdk-v3.0";

// Initialize connection and provider
const connection = new Connection(process.env.HELIUS_RPC_URL || "");
const wallet = new Wallet(Keypair.generate()); // Replace with your wallet
const provider = new AnchorProvider(connection, wallet, {
  commitment: "finalized",
});

// Create SDK instance
const sdk = new PumpFunSDK(provider);

Usage Options

The SDK provides two main approaches:

  1. Direct Methods: Simplified methods that handle the entire transaction flow
  2. Instruction Generation: Generate raw instructions for custom transaction building

1. Direct Methods

Create and Buy Token

import { Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";

// Generate a new mint keypair
const mint = Keypair.generate();
const creator = Keypair.generate(); // Your funded wallet

// Token metadata
const tokenMetadata = {
  name: "My Token",
  symbol: "MTK",
  description: "A test token created with PumpFun SDK",
  file: new Blob([/* your image file */]), // PNG/JPG file as Blob
  twitter: "https://twitter.com/mytoken",
  telegram: "https://t.me/mytoken",
  website: "https://mytoken.com"
};

// Create and buy token in one transaction
const result = await sdk.createAndBuy(
  creator,                                    // Creator keypair
  mint,                                       // Mint keypair
  tokenMetadata,                             // Token metadata
  BigInt(0.01 * LAMPORTS_PER_SOL),          // Buy amount in lamports (0.01 SOL)
  500n,                                      // Slippage basis points (5%)
  {                                          // Priority fees (optional)
    unitLimit: 250000,
    unitPrice: 250000,
  }
);

if (result.success) {
  console.log("Token created successfully!");
  console.log(`https://pump.fun/${mint.publicKey.toBase58()}`);
}

Buy Existing Token

const buyResult = await sdk.buy(
  buyer,                                     // Buyer keypair
  mint.publicKey,                           // Token mint address
  BigInt(0.01 * LAMPORTS_PER_SOL),         // Buy amount in lamports
  500n,                                     // Slippage basis points (5%)
  {                                         // Priority fees (optional)
    unitLimit: 250000,
    unitPrice: 250000,
  }
);

Sell Token

// Get current token balance
const tokenBalance = await sdk.getTokenBalance(mint.publicKey, seller.publicKey);

const sellResult = await sdk.sell(
  seller,                                   // Seller keypair
  mint.publicKey,                          // Token mint address
  tokenBalance,                            // Amount to sell (in token base units)
  500n,                                    // Slippage basis points (5%)
  {                                        // Priority fees (optional)
    unitLimit: 250000,
    unitPrice: 250000,
  }
);

2. Instruction Generation

For advanced users who want to build custom transactions:

import { Transaction } from "@solana/web3.js";
import { calculateWithSlippageBuy } from "pumpdotfun-sdk-v3.0";

// Create token instruction
const createTokenIx = await sdk.getCreateInstructions(
  creator,                        // Creator keypair
  "My Token",                              // Token name
  "MTK",                                   // Token symbol
  "https://metadata-uri.com/token.json",   // Metadata URI
  mint                                     // Token mint keypair
);

// Get global account for calculations
const globalAccount = await sdk.getGlobalAccount();

// Generate buy instruction
const buyAmountSol = BigInt(0.01 * LAMPORTS_PER_SOL);
const buyAmount = globalAccount.getInitialBuyPrice(buyAmountSol);
const buyAmountWithSlippage = calculateWithSlippageBuy(
  buyAmountSol,
  500n // 5% slippage
);

const buyTokenIx = await sdk.getBuyInstructions(
  buyer.publicKey,                         // Buyer public key
  mint.publicKey,                          // Token mint
  globalAccount.feeRecipient,              // Fee recipient
  buyAmount,                               // Token amount to buy
  buyAmountWithSlippage                    // Max SOL to spend
);

// Generate sell instruction
const sellTokenIx = await sdk.getSellInstructionsByTokenAmount(
  seller.publicKey,                        // Seller public key
  mint.publicKey,                          // Token mint
  sellTokenAmount,                         // Amount to sell
  500n                                     // Slippage basis points
);

// Build and send custom transaction
const transaction = new Transaction()
  .add(createTokenIx)
  .add(buyTokenIx);

// Sign and send transaction with your preferred method

Event Listening

// Listen to token events
sdk.addEventListener("createEvent", (event) => {
  console.log("New token created:", event.mint.toBase58());
});

sdk.addEventListener("tradeEvent", (event) => {
  console.log(`${event.isBuy ? 'Buy' : 'Sell'}: ${event.tokenAmount} tokens`);
});

Types

interface CreateTokenMetadata {
  name: string;
  symbol: string;
  description: string;
  file: Blob;
  twitter?: string;
  telegram?: string;
  website?: string;
}

interface PriorityFee {
  unitLimit: number;
  unitPrice: number;
}

interface TransactionResult {
  signature?: string;
  success: boolean;
  error?: unknown;
}

Disclaimer

This software is provided "as is," without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

Use at your own risk. The authors take no responsibility for any harm or damage caused by the use of this software. Users are responsible for ensuring the suitability and safety of this software for their specific use cases.

License

MIT