Programmatically launch pump.fun tokens with Python support
Project description
Pump.Fun Token Launcher (Python)
A clean Python package for programmatically launching tokens on pump.fun.
Features
- ๐ Simple, intuitive API
- ๐ง Comprehensive error handling
- ๐ฆ Clean package structure
- ๐งช Full test coverage
- ๐ Extensive documentation
- ๐ Retry logic for reliability
- โก Built on solders for performance
- ๐ Custom mint keypair support
Installation
pip install pump-fun-token-launcher
Requirements
- Python 3.8+
- A Solana wallet with sufficient SOL balance
- Valid Solana RPC endpoint access
Quick Start
Basic Usage
import asyncio
from pump_fun_launcher import launch_token, TokenConfig
async def main():
config = TokenConfig(
name="My Awesome Token",
symbol="MAT",
metadata_url="https://arweave.net/your-metadata-hash",
initial_buy=0.001, # SOL amount for initial buy
priority_fee=0.0001 # SOL amount for priority fee
)
private_key = "your_base58_or_base64_encoded_private_key"
result = await launch_token(config, private_key)
if result.success:
print(f"๐ Success! Token: {result.token_address}")
print(f"Transaction: {result.signature}")
print(f"View on Pump.fun: https://pump.fun/{result.token_address}")
else:
print(f"โ Failed: {result.error}")
asyncio.run(main())
Using Environment Variables
import os
import asyncio
from pump_fun_launcher import launch_token, TokenConfig
async def main():
config = TokenConfig(
name="My Token",
symbol="MTK",
metadata_url="https://arweave.net/metadata-hash",
initial_buy=0.001
)
# Use environment variable for private key
private_key = os.getenv("SOLANA_PRIVATE_KEY")
result = await launch_token(config, private_key)
print(result) # Pretty printed result
asyncio.run(main())
Custom Mint Keypair
from solders.keypair import Keypair
from pump_fun_launcher import launch_token, TokenConfig
async def main():
# Generate or provide your own mint keypair
custom_mint = Keypair()
print(f"Custom mint address: {custom_mint.pubkey()}")
config = TokenConfig(
name="Custom Mint Token",
symbol="CMT",
metadata_url="https://arweave.net/metadata-hash",
initial_buy=0.001,
mint_keypair=custom_mint # โ Use custom mint
)
result = await launch_token(config, private_key)
if result.success:
print(f"Token created at: {result.token_address}")
# result.token_address == str(custom_mint.pubkey())
asyncio.run(main())
Package Structure
pump_fun_launcher/
โโโ __init__.py # Main exports
โโโ launcher.py # Core launch functionality
โโโ config.py # Configuration classes
โโโ types.py # Type definitions
โโโ constants.py # Solana program constants
โโโ utils.py # Utility functions
โโโ instructions.py # Solana instruction builders
examples/
โโโ basic_example.py # Simple launch example
โโโ interactive_example.py # CLI interactive launcher
โโโ advanced_example.py # Batch launches with retry logic
โโโ custom_mint_example.py # Custom mint keypair examples
โโโ batch_with_custom_mints.py # Batch launch with custom mints
tests/
โโโ test_config.py # Configuration tests
โโโ test_utils.py # Utility function tests
โโโ test_custom_mint.py # Custom mint tests
โโโ conftest.py # Test configuration
API Reference
TokenConfig
@dataclass
class TokenConfig:
name: str # Token name (required)
symbol: str # Token symbol (required, max 10 chars)
metadata_url: str # Token metadata URL (required)
initial_buy: float = 0.01 # Initial buy amount in SOL
priority_fee: float = 0.001 # Priority fee in SOL
mint_keypair: Optional[Keypair] = None # Custom mint keypair (optional)
launch_token()
async def launch_token(
config: TokenConfig,
private_key: Union[str, Keypair],
rpc_url: str = "https://api.mainnet-beta.solana.com"
) -> LaunchResult
LaunchResult
@dataclass
class LaunchResult:
success: bool
signature: Optional[str] = None
token_address: Optional[str] = None
error: Optional[str] = None
Examples
Run Interactive Example
python examples/interactive_example.py
This will guide you through token creation with prompts for all parameters.
Custom Mint Examples
python examples/custom_mint_example.py
Choose from:
- Custom mint keypair generation
- Auto-generated mint (default)
- Deterministic mint from seed
Batch Token Launch
# See examples/advanced_example.py for full implementation
configs = [
TokenConfig(name="Alpha Token", symbol="ALPHA", metadata_url="..."),
TokenConfig(name="Beta Token", symbol="BETA", metadata_url="..."),
]
for config in configs:
result = await launch_with_retry(config, private_key, max_retries=3)
print(f"Token {config.name}: {'โ
' if result.success else 'โ'}")
Batch with Custom Mints
# Assign specific mint addresses to each token
tokens = [
(TokenConfig(name="Alpha", symbol="A", ...), Keypair()),
(TokenConfig(name="Beta", symbol="B", ...), Keypair()),
]
for config, mint in tokens:
config.mint_keypair = mint
result = await launch_token(config, private_key)
print(f"Token {config.name} at {result.token_address}")
Mint Keypair Options
Auto-Generated (Default)
config = TokenConfig(name="Token", symbol="TKN", metadata_url="...")
# mint_keypair is None, so a random one will be generated
Custom Keypair
from solders.keypair import Keypair
custom_mint = Keypair()
config = TokenConfig(
name="Token",
symbol="TKN",
metadata_url="...",
mint_keypair=custom_mint
)
Deterministic from Seed
seed = "my-reproducible-seed".encode('utf-8')[:32].ljust(32, b'\0')
deterministic_mint = Keypair.from_bytes(seed)
config = TokenConfig(
name="Token",
symbol="TKN",
metadata_url="...",
mint_keypair=deterministic_mint
)
# Always creates the same token address!
Development
Setup Development Environment
git clone https://github.com/bilix-software/pump-fun-token-launcher-python.git
cd pump-fun-token-launcher-python
pip install -e .[dev]
Run Tests
pytest
Code Formatting
black pump_fun_launcher/
isort pump_fun_launcher/
Type Checking
mypy pump_fun_launcher/
Error Handling
The package includes comprehensive error handling:
result = await launch_token(config, private_key)
if not result.success:
if "insufficient" in result.error.lower():
print("๐ฐ Insufficient wallet balance")
elif "invalid" in result.error.lower():
print("๐ Invalid configuration or private key")
elif "timeout" in result.error.lower():
print("โฐ Transaction timed out - try increasing priority fee")
else:
print(f"โ Launch failed: {result.error}")
Environment Setup
-
Get SOL: Ensure your wallet has sufficient SOL for:
- Transaction fees (~0.01 SOL)
- Initial token purchase (if specified)
- Priority fees
-
Private Key: Set your private key as an environment variable:
export SOLANA_PRIVATE_KEY="your_base58_or_base64_key_here"
-
Metadata: Upload your token metadata to IPFS or Arweave and use that URL.
Dependencies
solana- Core Solana Python librarysolders- Fast Solana primitivesbase58- Base58 encoding/decoding
License
MIT License - see LICENSE file for details.
Support
- ๐ Issues: GitHub Issues
- ๐ฌ Telegram: @bilixsoftware
- ๐ง Email: info@bilix.io
Contributing
Contributions welcome! Please read the contributing guidelines and submit pull requests.
โ ๏ธ Disclaimer: This tool is for educational purposes. Always test on devnet first. Cryptocurrency development involves financial risk.
Tips
JATt1ta9GcbVMThdL18rXUqHn3toCMjWkHWtxM5WN3ec
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pump_fun_token_launcher-1.0.0.tar.gz.
File metadata
- Download URL: pump_fun_token_launcher-1.0.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52552428b70885b6f4413cd49cb62deb799642f69ab678b9b716bcc9fbc08733
|
|
| MD5 |
e6773525f0134280ef65563e99eeb322
|
|
| BLAKE2b-256 |
f060c20db3d0ec043dd0008a625be0ee7592fb3269f8cf7cb26cceeaa84d794f
|
File details
Details for the file pump_fun_token_launcher-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pump_fun_token_launcher-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
419fee411bb235d0971f7896fc226b68cece63825d827153be0caedf8a91cfb4
|
|
| MD5 |
2c0ebb65f9912072b8661723d1cdbb46
|
|
| BLAKE2b-256 |
d0e39e1e1859f301f2059bfa8585af7a1e683beaaaaac6906485702968328583
|