SDK for interacting with Pump.fun
npm install pumpfun-sdkA 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.


- PumpFun SDK
- Table of Contents
- Installation
- Features
- Quick Start
- Detailed Usage
- Trading Operations
- Buy Operations
- Sell Operations
- Wallet Management
- Configuration
- WalletGenerator Configuration
- Error Handling
- API Reference
- Trading Functions
- pumpFunBuy
- pumpFunSell
- Wallet Management
- WalletGenerator Methods
- Examples
- Complete Trading Workflow
- Contributing
- Development Setup
- Building and Testing
- Contribution Guidelines
- Code Review Process
- Security
- Security Considerations
- License
- Troubleshooting
- Common Issues
- Support
- Release Process
- Version Numbering
``bash`
npm install pumpfun-sdkor
yarn add pumpfun-sdk
- Trading Operations
- Buy and sell tokens on Pump.fun
- Transaction simulation before execution
- Priority fee management
- Slippage protection
- Transaction tracking to finality
- Market Data
- Token details and pricing
- Market overview with trending tokens
- Transaction history
- Price quotes without execution
- Wallet Management
- Generate multiple wallets
- Distribute SOL to wallets
- Collect remaining funds
- Batch operations support
- Advanced Utilities
- Enhanced retry mechanism with intelligent backoff
- Comprehensive error classification
- Transaction confirmation tracking
- Type-safe interfaces and validation
`typescript
import {
pumpFunBuy,
pumpFunSell,
TransactionMode,
getCoinData,
getMarketOverview,
getBuyPriceQuote,
WalletGenerator
} from 'pumpfun-sdk';
// Get market overview with trending tokens
const market = await getMarketOverview(10); // Top 10 tokens
console.log(Total tokens: ${market.totalTokens});Top token: ${market.tokens[0].name} (${market.tokens[0].mint})
console.log();
// Get detailed coin data
const coin = await getCoinData('TOKEN_MINT_ADDRESS');
console.log(${coin.name} price: ${coin.price_sol} SOL);
// Get price quote without executing a transaction
const quote = await getBuyPriceQuote('TOKEN_MINT_ADDRESS', 0.1); // 0.1 SOL
console.log(Expected tokens: ${quote.expectedOutputAmount});Price impact: ${(quote.priceImpact * 100).toFixed(2)}%
console.log();
// Execute a buy operation with custom configuration
const result = await pumpFunBuy(
TransactionMode.Execution,
'YOUR_PRIVATE_KEY',
'TOKEN_MINT_ADDRESS',
0.1, // SOL amount
0.0001, // Priority fee
0.25, // Slippage
{ // Optional configuration
rpcUrl: 'https://api.mainnet-beta.solana.com',
commitment: 'confirmed',
trackTx: true
}
);
console.log(Transaction signature: ${result.signature});Tokens purchased: ${result.expectedOutput}
console.log();
// Initialize wallet generator for multi-wallet operations
const generator = new WalletGenerator({
rpcUrl: 'https://api.mainnet-beta.solana.com',
numberOfWallets: 10,
solanaToDistribute: 0.1
});
// Generate wallets
const wallets = generator.generateWallets();
`
#### Buy Operations
The SDK provides a comprehensive interface for buying tokens:
`typescript
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:
`typescript`
await pumpFunSell(
TransactionMode.Execution,
privateKey,
mintAddress,
tokenAmount, // Amount of tokens to sell
priorityFee,
slippage
);
The WalletGenerator class provides comprehensive wallet management features:
`typescript
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);
`
#### WalletGenerator Configuration
`typescript`
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)
}
The SDK implements comprehensive error handling with retry mechanisms:
`typescriptFailed after ${error.attempts} attempts
try {
await pumpFunBuy(/ ... /);
} catch (error) {
if (error instanceof RetryError) {
console.log();`
}
// Handle other errors
}
#### getCoinData
`typescript`
function getCoinData(mintStr: string): Promise
#### getMarketOverview
`typescript`
function getMarketOverview(limit: number = 50): Promise
#### getTokenTransactionHistory
`typescript`
function getTokenTransactionHistory(mintStr: string, limit: number = 20): Promise
#### getBuyPriceQuote
`typescript`
function getBuyPriceQuote(mintStr: string, solAmount: number): Promise
#### getSellPriceQuote
`typescript`
function getSellPriceQuote(mintStr: string, tokenAmount: number): Promise
#### pumpFunBuy
`typescript`
function pumpFunBuy(
transactionMode: TransactionMode,
payerPrivateKey: string,
mintStr: string,
solIn: number,
priorityFeeInSol?: number,
slippageDecimal?: number,
config?: SwapConfig
): Promise<{
success: boolean;
signature?: string;
expectedOutput: number;
inputAmount: number;
outputToken: string;
simulation?: any;
logs?: string[];
}>
#### pumpFunSell
`typescript`
function pumpFunSell(
transactionMode: TransactionMode,
payerPrivateKey: string,
mintStr: string,
tokenBalance: number,
priorityFeeInSol?: number,
slippageDecimal?: number,
config?: SwapConfig
): Promise<{
success: boolean;
signature?: string;
expectedOutput: number;
inputAmount: number;
outputToken: string;
simulation?: any;
logs?: string[];
}>
#### WalletGenerator Methods
`typescript`
class WalletGenerator {
generateWallets(): WalletData[];
distributeToWallets(mainWalletPrivateKey: string, wallets: WalletData[]): Promise
success: boolean;
error?: string;
}>>;
collectFromAllWallets(wallets: WalletData[], destinationPublicKey: string): Promise
}
`typescript
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);
}
`
We welcome contributions to the PumpFun SDK! Here's how you can help:
1. Clone the repository:
`bash`
git clone https://github.com/yourusername/pumpfun-sdk.git
cd pumpfun-sdk
2. Install dependencies:
`bash`
npm install
3. Create a new branch:
`bash`
git checkout -b feature/your-feature-name
1. Build the project:
`bash`
npm run build
2. Run tests:
`bash``
npm test
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
1. All submissions require review
2. Contributors should respond to comments
3. Keep discussions focused and professional
4. Address all feedback before merging
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
This project is licensed under the MIT License - see the LICENSE file for details.
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
For support, please:
1. Check the documentation
2. Search existing issues
3. Create a new issue with detailed information
---
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.