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.
- PumpFun SDK
npm install pumpfun-sdk
# or
yarn add pumpfun-sdk
-
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
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
);
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)
);
Similar interface for selling tokens:
await pumpFunSell(
TransactionMode.Execution,
privateKey,
mintAddress,
tokenAmount, // Amount of tokens to sell
priorityFee,
slippage
);
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);
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:
try {
await pumpFunBuy(/* ... */);
} catch (error) {
if (error instanceof RetryError) {
console.log(`Failed after ${error.attempts} attempts`);
}
// Handle other errors
}
function pumpFunBuy(
transactionMode: TransactionMode,
payerPrivateKey: string,
mintStr: string,
solIn: number,
priorityFeeInSol?: number,
slippageDecimal?: number
): Promise<void>
function pumpFunSell(
transactionMode: TransactionMode,
payerPrivateKey: string,
mintStr: string,
tokenBalance: number,
priorityFeeInSol?: number,
slippageDecimal?: number
): Promise<void>
class WalletGenerator {
generateWallets(): WalletData[];
distributeToWallets(mainWalletPrivateKey: string, wallets: WalletData[]): Promise<Array<{
publicKey: string;
success: boolean;
error?: string;
}>>;
collectFromAllWallets(wallets: WalletData[], destinationPublicKey: string): Promise<TransferResult[]>;
}
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:
- Clone the repository:
git clone https://github.com/yourusername/pumpfun-sdk.git
cd pumpfun-sdk
- Install dependencies:
npm install
- Create a new branch:
git checkout -b feature/your-feature-name
- Build the project:
npm run build
- Run tests:
npm test
-
Code Style
- Follow TypeScript best practices
- Use meaningful variable names
- Add appropriate comments
- Include type definitions
-
Testing
- Write unit tests for new features
- Ensure all tests pass
- Add integration tests when necessary
-
Documentation
- Update README.md if needed
- Document new features
- Add JSDoc comments to functions
-
Pull Requests
- Create descriptive pull request titles
- Reference any related issues
- Provide a clear description of changes
- Update documentation as needed
- All submissions require review
- Contributors should respond to comments
- Keep discussions focused and professional
- Address all feedback before merging
-
Private Key Handling
- Never log private keys
- Use secure key storage
- Implement proper key rotation
-
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.
-
Transaction Failed
- Check RPC endpoint status
- Verify account balances
- Check for rate limiting
-
Wallet Generation Issues
- Verify RPC connection
- Check system requirements
- Ensure proper permissions
For support, please:
- Check the documentation
- Search existing issues
- 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.