Skip to content

A comprehensive TypeScript/JavaScript SDK for interacting with Pump.fun on the Solana blockchain. This SDK provides utilities for trading operations, wallet management, volume booster and automated trading strategies.

License

Notifications You must be signed in to change notification settings

Synthexlab/pumpfun-sdk

Repository files navigation

PumpFun SDK

A comprehensive TypeScript/JavaScript SDK for interacting with Pump.fun on the Solana blockchain. This SDK provides utilities for trading operations, wallet management, and automated trading strategies.

npm version License: MIT

Table of Contents

Installation

npm install pumpfun-sdk
# or
yarn add pumpfun-sdk

Features

  • Trading Operations

    • Buy and sell tokens on Pump.fun
    • Transaction simulation before execution
    • Priority fee management
    • Slippage protection
  • Wallet Management

    • Generate multiple wallets
    • Distribute SOL to wallets
    • Collect remaining funds
    • Batch operations support
  • Advanced Utilities

    • Retry mechanism for failed operations
    • Rate limiting and backoff strategies
    • Comprehensive error handling
    • Transaction confirmation tracking

Quick Start

import { pumpFunBuy, pumpFunSell, TransactionMode, WalletGenerator } from 'pumpfun-sdk';

// Initialize wallet generator
const generator = new WalletGenerator({
    rpcUrl: 'https://api.devnet.solana.com',
    numberOfWallets: 10,
    solanaToDistribute: 0.1
});

// Generate wallets
const wallets = generator.generateWallets();

// Execute a buy operation
await pumpFunBuy(
    TransactionMode.Execution,
    'YOUR_PRIVATE_KEY',
    'TOKEN_MINT_ADDRESS',
    0.1,          // SOL amount
    0.0001,       // Priority fee
    0.25          // Slippage
);

Detailed Usage

Trading Operations

Buy Operations

The SDK provides a comprehensive interface for buying tokens:

import { pumpFunBuy, TransactionMode } from 'pumpfun-sdk';

await pumpFunBuy(
    TransactionMode.Execution,  // or TransactionMode.Simulation
    privateKey,                 // Base58 encoded private key
    mintAddress,               // Token mint address
    solAmount,                 // Amount of SOL to spend
    priorityFee,               // Optional priority fee in SOL
    slippage                   // Optional slippage tolerance (0-1)
);

Sell Operations

Similar interface for selling tokens:

await pumpFunSell(
    TransactionMode.Execution,
    privateKey,
    mintAddress,
    tokenAmount,               // Amount of tokens to sell
    priorityFee,
    slippage
);

Wallet Management

The WalletGenerator class provides comprehensive wallet management features:

const generator = new WalletGenerator({
    rpcUrl: 'https://api.devnet.solana.com',
    numberOfWallets: 10,
    solanaToDistribute: 0.1,
    batchSize: 5,
    delayMs: 1000,
    minRemainingBalance: 5000
});

// Generate wallets
const wallets = generator.generateWallets();

// Distribute SOL
await generator.distributeToWallets(mainWalletPrivateKey, wallets);

// Collect remaining funds
await generator.collectFromAllWallets(wallets, destinationPublicKey);

Configuration

WalletGenerator Configuration

interface WalletGeneratorConfig {
    rpcUrl: string;              // Solana RPC endpoint
    numberOfWallets?: number;    // Number of wallets to generate (default: 100)
    solanaToDistribute?: number; // SOL amount to distribute (default: 2)
    batchSize?: number;         // Batch size for operations (default: 5)
    delayMs?: number;           // Delay between operations (default: 1000)
    minRemainingBalance?: number; // Min balance to keep (default: 5000 lamports)
}

Error Handling

The SDK implements comprehensive error handling with retry mechanisms:

try {
    await pumpFunBuy(/* ... */);
} catch (error) {
    if (error instanceof RetryError) {
        console.log(`Failed after ${error.attempts} attempts`);
    }
    // Handle other errors
}

API Reference

Trading Functions

pumpFunBuy

function pumpFunBuy(
    transactionMode: TransactionMode,
    payerPrivateKey: string,
    mintStr: string,
    solIn: number,
    priorityFeeInSol?: number,
    slippageDecimal?: number
): Promise<void>

pumpFunSell

function pumpFunSell(
    transactionMode: TransactionMode,
    payerPrivateKey: string,
    mintStr: string,
    tokenBalance: number,
    priorityFeeInSol?: number,
    slippageDecimal?: number
): Promise<void>

Wallet Management

WalletGenerator Methods

class WalletGenerator {
    generateWallets(): WalletData[];
    distributeToWallets(mainWalletPrivateKey: string, wallets: WalletData[]): Promise<Array<{
        publicKey: string;
        success: boolean;
        error?: string;
    }>>;
    collectFromAllWallets(wallets: WalletData[], destinationPublicKey: string): Promise<TransferResult[]>;
}

Examples

Complete Trading Workflow

import { WalletGenerator, TransactionMode, pumpFunBuy, pumpFunSell } from 'pumpfun-sdk';

async function tradingWorkflow() {
    // Initialize generator
    const generator = new WalletGenerator({
        rpcUrl: 'https://api.devnet.solana.com',
        numberOfWallets: 5
    });

    // Generate wallets
    const wallets = generator.generateWallets();

    // Distribute SOL
    await generator.distributeToWallets(mainWalletPrivateKey, wallets);

    // Execute trades
    for (const wallet of wallets) {
        // Buy operation
        await pumpFunBuy(
            TransactionMode.Execution,
            wallet.secretKey,
            mintAddress,
            0.05
        );

        // Sell operation
        await pumpFunSell(
            TransactionMode.Execution,
            wallet.secretKey,
            mintAddress,
            1000
        );
    }

    // Collect remaining funds
    await generator.collectFromAllWallets(wallets, destinationPublicKey);
}

Contributing

We welcome contributions to the PumpFun SDK! Here's how you can help:

Development Setup

  1. Clone the repository:
git clone https://github.com/yourusername/pumpfun-sdk.git
cd pumpfun-sdk
  1. Install dependencies:
npm install
  1. Create a new branch:
git checkout -b feature/your-feature-name

Building and Testing

  1. Build the project:
npm run build
  1. Run tests:
npm test

Contribution Guidelines

  1. Code Style

    • Follow TypeScript best practices
    • Use meaningful variable names
    • Add appropriate comments
    • Include type definitions
  2. Testing

    • Write unit tests for new features
    • Ensure all tests pass
    • Add integration tests when necessary
  3. Documentation

    • Update README.md if needed
    • Document new features
    • Add JSDoc comments to functions
  4. Pull Requests

    • Create descriptive pull request titles
    • Reference any related issues
    • Provide a clear description of changes
    • Update documentation as needed

Code Review Process

  1. All submissions require review
  2. Contributors should respond to comments
  3. Keep discussions focused and professional
  4. Address all feedback before merging

Security

Security Considerations

  1. Private Key Handling

    • Never log private keys
    • Use secure key storage
    • Implement proper key rotation
  2. Transaction Safety

    • Always use simulation before execution
    • Implement proper slippage protection
    • Handle transaction errors properly

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Common Issues

  1. Transaction Failed

    • Check RPC endpoint status
    • Verify account balances
    • Check for rate limiting
  2. Wallet Generation Issues

    • Verify RPC connection
    • Check system requirements
    • Ensure proper permissions

Support

For support, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue with detailed information

Release Process

Version Numbering

We follow Semantic Versioning:

  • MAJOR version for incompatible API changes
  • MINOR version for backwards-compatible functionality
  • PATCH version for backwards-compatible bug fixes

Built with ❤️ for the Solana community.

About

A comprehensive TypeScript/JavaScript SDK for interacting with Pump.fun on the Solana blockchain. This SDK provides utilities for trading operations, wallet management, volume booster and automated trading strategies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published