What This Document Covers:
- Production-ready Solana token launching via pump.fun
- Modular architecture (9 components)
- Atomic CREATE+ATA+BUY transactions
- API integration for UI recognition
- Complete usage examples and troubleshooting
Sections in This Document:
- Core Responsibilities
- Architecture Overview
- Quick Start
- Detailed Usage
- Configuration Reference
- Technical Specifications
- Troubleshooting
- Integration Patterns
Related Documentation:
- → README.md - Project overview
- → WEB_UI.md - Web interface for launch management
- → VORTEX_INTEGRATION.md - Advanced trading integration (coming soon)
- → ../architecture/DOMAIN_ARCHITECTURE.md - Domain event patterns
Context Tags: #blockchain #pump-fun #solana #token-launch #atomic-transactions
The pump_fun module (src/pump_fun/) is responsible for:
- Token Creation: Complete pump.fun token launching with atomic CREATE+ATA+BUY transactions
- API Integration: Automatic token registration with pump.fun for UI recognition
- Transaction Management: Solana transaction construction, signing, and confirmation
- Metadata Handling: IPFS metadata upload and management
- Network Operations: RPC client management with timeout and retry logic
- Wallet Management: Keypair generation, loading, and secure storage
- Program Interaction: Direct integration with pump.fun Solana program
src/pump_fun/
├── launcher.py # Main launcher interface - primary entry point
├── config.py # Network configurations (mainnet/devnet)
├── api_client.py # Pump.fun API client for token registration
├── metadata_client.py # IPFS metadata upload handling
├── network_client.py # Solana RPC network operations
├── wallet_manager.py # Keypair and wallet management
├── transaction_builder.py # Solana transaction construction
├── instruction_builder.py # Pump.fun instruction serialization
├── pda_utils.py # Program Derived Address utilities
└── examples/ # Usage examples and demonstrations
├── basic_launch.py # Simple token launch
└── bundled_launch.py # Multi-wallet launch
| Component | Module | Key Responsibilities |
|---|---|---|
| PumpFunLauncher | launcher.py |
Main entry point; orchestration; error handling; API integration |
| PumpFunConfig | config.py |
Network config; program constants (1.073B tokens, 30 SOL curve); transaction settings |
| PumpFunAPIClient | api_client.py |
Token registration with pump.fun backend; UI recognition; profile integration |
| TransactionBuilder | transaction_builder.py |
Atomic CREATE+ATA+BUY transactions; bonding curve calculations; fee management |
| PumpFunInstructions | instruction_builder.py |
CREATE/BUY instruction building; data serialization; discriminators; price calculations |
| NetworkClient | network_client.py |
RPC operations; balance checks; transaction broadcasting; confirmation |
| MetadataClient | metadata_client.py |
IPFS uploads; image processing (PNG/JPG/GIF); validation |
| WalletManager | wallet_manager.py |
Keypair generation/loading/saving; CSV/JSON/bytes format support |
| PumpFunPDAs | pda_utils.py |
Program Derived Address derivation; bonding curve/metadata account resolution |
import asyncio
from src.pump_fun.launcher import PumpFunLauncher
from src.models.token_models import TokenMetadata, LaunchConfig
async def launch_token():
# Initialize launcher for devnet testing
launcher = PumpFunLauncher(network="devnet")
# Generate creator keypair (or load from file)
creator_keypair = launcher.generate_keypair()
# Define token metadata
metadata = TokenMetadata(
name="Test Token",
ticker="TEST",
description="A test token on pump.fun",
image_path="goose.jpeg", # Local file in res/
website="https://example.com",
twitter="https://x.com/testtoken"
)
# Launch configuration with dev buy
config = LaunchConfig(dev_buy_sol=0.01)
# Launch token with atomic transaction
result = await launcher.create_and_buy_token(metadata, config, creator_keypair)
if result['success']:
print(f"✅ Token launched: {result['mint_address']}")
print(f"📊 Transaction: {result['transaction_signature']}")
print(f"🌐 pump.fun URL: {result.get('pump_fun_url', 'N/A')}")
# API registration results
if result.get('api_registration', {}).get('success'):
print("✅ Token registered with pump.fun API")
else:
print("⚠️ Token launch succeeded but API registration failed")
else:
print(f"❌ Token launch failed: {result.get('error', 'Unknown error')}")
await launcher.close()
# Run the example
asyncio.run(launch_token())from src.pump_fun.launcher import PumpFunLauncher
from src.pump_fun.config import PumpFunConfig
# Custom mainnet configuration
config = PumpFunConfig(
network="mainnet",
rpc_url="https://api.mainnet-beta.solana.com",
compute_unit_limit=500_000,
compute_unit_price=150_000, # Higher priority fee for mainnet
confirmation_timeout_mainnet=45
)
launcher = PumpFunLauncher(network="mainnet", config=config)# Generate new keypair
keypair = launcher.generate_keypair()
# Load keypair from file (supports multiple formats)
keypair = launcher.load_keypair_from_file("path/to/wallet.csv")
# Save keypair to file (formats: CSV, JSON, Bytes)
success = launcher.save_keypair_to_file(keypair, "new_wallet.csv", format_type="base58")
# Get wallet information
info = launcher.get_keypair_info(keypair)
print(f"Address: {info['address']}")
print(f"Balance: {info['balance']} SOL")# Check wallet balance
balance = await launcher.check_balance(keypair.pubkey())
print(f"Current balance: {balance} SOL")
# Ensure wallet has minimum funding (0.01 SOL mainnet, 0.1 SOL devnet)
funded = await launcher.ensure_funded(keypair.pubkey(), min_balance=0.1)
if not funded:
print("❌ Insufficient balance - please fund wallet")from src.models.token_models import TokenMetadata
# Complete metadata with all social links
metadata = TokenMetadata(
name="Advanced Token",
ticker="ADV",
description="A comprehensive token with full social presence",
# Image options (priority: image_url > image_data_uri > image_path):
image_url="https://example.com/token.png", # Remote URL (fastest)
image_data_uri="data:image/png;base64,iVBOR...", # Base64 (no upload)
image_path="local_image.png", # Local file (requires IPFS upload)
# Social media links
website="https://advancedtoken.com",
twitter="https://x.com/advancedtoken",
telegram="https://t.me/advancedtoken",
discord="https://discord.gg/advancedtoken",
github="https://github.com/advancedtoken"
)# Launch with detailed monitoring
result = await launcher.create_and_buy_token(metadata, config, creator_keypair)
if result['success']:
signature = result['transaction_signature']
# Wait for confirmation
confirmed = await launcher.wait_for_confirmation(signature, timeout=60)
if confirmed:
print("✅ Transaction confirmed on-chain")
# Get explorer URLs (Solana Explorer + Solscan)
explorer_url = launcher.get_explorer_url(signature)
solscan_url = launcher.get_solscan_url(signature)
print(f"🔗 Explorer: {explorer_url}")
print(f"🔗 Solscan: {solscan_url}")
else:
print("⏳ Transaction confirmation timed out")Pydantic-validated configuration with network-specific defaults:
| Category | Parameter | Default | Notes |
|---|---|---|---|
| Network | network | "mainnet" | "mainnet" or "devnet" |
| rpc_url | "https://api.mainnet-beta.solana.com" | Auto-selected by network | |
| commitment | "confirmed" | ||
| Program | program_id | "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" | Verified pump.fun program |
| token_decimals | 6 | Fixed by protocol | |
| total_supply | 1,000,000,000 | Fixed by protocol | |
| Transaction | compute_unit_limit | 400,000 | Standard for CREATE+ATA+BUY |
| compute_unit_price | 100,000 | Priority fee (micro-lamports) | |
| confirmation_timeout_mainnet | 15 | Seconds | |
| confirmation_timeout_devnet | 10 | Seconds | |
| Balance | min_balance_mainnet | 0.01 | SOL required |
| min_balance_devnet | 0.1 | SOL required | |
| Bonding Curve | virtual_token_reserves | 1.073B (with decimals) | Protocol constant |
| virtual_sol_reserves | 30 SOL (lamports) | Protocol constant | |
| real_token_reserves | 793.1M (with decimals) | Initial state | |
| Trading | max_slippage | 0.5 | 50% maximum |
Methods: get_rpc_url(), get_min_balance(), get_confirmation_timeout() return network-specific values
- Program ID:
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P - Token Standard: SPL Token with 6 decimals (pump.fun specific)
- Total Supply: 1,000,000,000 tokens (fixed by protocol)
- Bonding Curve: Initial state with 1.073B virtual tokens, 30 SOL virtual liquidity
| Instruction | Uint64 | Bytes | Module |
|---|---|---|---|
| CREATE | 8576854823835016728 | [24, 30, 200, 40, 5, 28, 7, 119] | instruction_builder.py, config.py |
| BUY | 16927863322537952870 | [102, 6, 61, 18, 1, 218, 235, 234] | instruction_builder.py, config.py |
- Atomic Design: CREATE + ATA + BUY in single transaction
- Compute Budget: 400,000 compute units standard
- Priority Fee: 100,000 micro-lamports (0.0001 SOL)
- Slippage Protection: 30% maximum slippage for safety
- Smart Confirmation: Timeout with fallback verification
Transaction Structure:
Transaction
├── Compute Budget Instruction (set limit)
├── Compute Budget Instruction (set priority fee)
├── CREATE Instruction (pump.fun program)
├── Associated Token Account Instruction (SPL Token)
└── BUY Instruction (pump.fun program)
Formula: Constant product model x * y = k (where x = token reserves, y = SOL reserves)
Calculation Steps:
- Add SOL purchase to virtual reserves:
new_sol = virtual_sol + buy_lamports - Calculate constant:
k = virtual_tokens * virtual_sol - Calculate new token reserves:
new_tokens = k / new_sol - Tokens received:
amount = virtual_tokens - new_tokens
Initial State: 1.073B virtual tokens, 30 SOL virtual reserves
Implementation: TransactionBuilder.calculate_buy_amount() in transaction_builder.py
- Token Registration: Automatic pump.fun backend registration
- UI Recognition: Ensures tokens appear in pump.fun interface
- Profile Integration: Tokens counted in creator profiles
- Status Tracking: Real-time registration status monitoring
Registration Endpoint: POST https://frontend-api.pump.fun/coins/{mint_address}
Payload Fields:
| Field | Type | Example | Required |
|---|---|---|---|
| mint | string | TOKEN_MINT_ADDRESS | Yes |
| name | string | Token Name | Yes |
| symbol | string | TICKER | Yes |
| description | string | Token description | Yes |
| image_uri | string | ipfs://... | Yes |
| metadata_uri | string | ipfs://... | Yes |
| creator | string | CREATOR_PUBKEY | Yes |
| signature | string | TRANSACTION_SIGNATURE | Yes |
| string | https://x.com/... | No | |
| telegram | string | https://t.me/... | No |
| website | string | https://example.com | No |
| Error | Cause | Solution | Reference |
|---|---|---|---|
| Insufficient balance | Wallet has < min SOL | Fund wallet (0.01 SOL mainnet, 0.1 devnet) or use faucet: solana airdrop 1 PUBKEY --url devnet |
Check: await launcher.check_balance(keypair.pubkey()) |
| Transaction timeout | Network congestion | Check explorer URL (may have succeeded) or increase confirmation_timeout_mainnet=45 |
Verify: await launcher.wait_for_confirmation(signature, timeout=60) |
| API registration failure | Backend unavailable | Token launched successfully - retry via PumpFunAPIClient().register_token() with mint_address + signature |
Launch succeeded, registration optional |
| Invalid program account | Wrong network/program ID | Verify program_id=6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P and config.get_rpc_url() |
Configuration |
| IPFS upload failure | Image format/size issue | Verify PNG/JPG/GIF < 10MB or convert to data URI: image_data_uri=f"data:image/png;base64,{base64.b64encode(path.read_bytes()).decode()}" |
Use data URI instead of local path |
Enable detailed logging for troubleshooting:
import logging
logging.basicConfig(level=logging.DEBUG)
launcher = PumpFunLauncher(network="devnet")
# All operations now log: transactions, PDAs, API requests, confirmations, errorsThe pump.fun launcher integrates with the project's domain architecture for automated workflows:
from src.domain.model.actions.memecoin_action import MemecoinAction
from src.models.token_models import TokenMetadata
# Convert domain MemecoinAction to pump.fun launch
def convert_memecoin_action_to_launch(action: MemecoinAction) -> TokenMetadata:
"""Convert domain MemecoinAction to TokenMetadata for pump.fun launch"""
return TokenMetadata(
name=action.token_name,
ticker=action.ticker,
description=action.description,
image_data_uri=f"data:image/jpeg;base64,{action.image_base64}",
website=action.social_links.get('website'),
twitter=action.social_links.get('twitter'),
telegram=action.social_links.get('telegram')
)
# Launch from domain action
metadata = convert_memecoin_action_to_launch(memecoin_action)
result = await launcher.create_and_buy_token(metadata, config, creator_keypair)# Launch multiple tokens with different wallets
for wallet in wallet_list:
result = await launcher.create_and_buy_token(
metadata=get_metadata_for_wallet(wallet),
config=LaunchConfig(dev_buy_sol=0.01),
creator_keypair=wallet
)
if result['success']:
print(f"✅ Token {result['mint_address']} launched")
# Rate limiting
await asyncio.sleep(1.0) # 1 second between launchesThe Web UI provides launch management through dedicated pages:
Launch Configuration (/launches.html):
- Create draft launches (wallets + SOL)
- Create complete launches (+ memecoin data)
- Schedule launches for specific times
- Execute launches immediately
Plan Launch (/plan_launch.html):
- Configure developer wallet + SOL
- Add bundling wallets + SOL amounts
- Select memecoin from generated collection
- Schedule or execute launch
Integration: Web UI → LaunchConfigurationOrchestrator → PumpFunLauncher → pump.fun
# Test on devnet (recommended for testing)
NETWORK=devnet python src/pump_fun/launcher.py
# Test on mainnet (ensure wallet is funded)
NETWORK=mainnet python src/pump_fun/launcher.py# Basic usage examples
python src/pump_fun/examples/basic_launch.py
# Multi-wallet bundled launch
python src/pump_fun/examples/bundled_launch.py- v2.1.0: Streamlined configuration and enhanced reliability
- Refactored PumpFunConfig with only essential fields
- Enhanced timeout handling with network-specific values
- Improved error handling and confirmation logic
- Production-tested atomic transaction support
- Complete pump.fun API integration with UI recognition
- Financial Risk: This tool handles real cryptocurrency transactions
- Testing Required: Always test on devnet before mainnet deployment
- Regulatory Compliance: Ensure compliance with local regulations
- No Guarantees: Authors not responsible for financial losses
Document Status: Complete
Last Updated: October 15, 2025
Implementation: src/pump_fun/ (9 modules)
Ready for production token launches on pump.fun! 🚀