Skip to main content

Programmatically launch pump.fun tokens with Python support

Project description

Pump.Fun Token Launcher (Python)

PyPI version Python License: MIT Solana

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

  1. Get SOL: Ensure your wallet has sufficient SOL for:

    • Transaction fees (~0.01 SOL)
    • Initial token purchase (if specified)
    • Priority fees
  2. Private Key: Set your private key as an environment variable:

    export SOLANA_PRIVATE_KEY="your_base58_or_base64_key_here"
    
  3. Metadata: Upload your token metadata to IPFS or Arweave and use that URL.

Dependencies

  • solana - Core Solana Python library
  • solders - Fast Solana primitives
  • base58 - Base58 encoding/decoding

License

MIT License - see LICENSE file for details.

Support

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pump_fun_token_launcher-1.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pump_fun_token_launcher-1.0.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

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

Hashes for pump_fun_token_launcher-1.0.0.tar.gz
Algorithm Hash digest
SHA256 52552428b70885b6f4413cd49cb62deb799642f69ab678b9b716bcc9fbc08733
MD5 e6773525f0134280ef65563e99eeb322
BLAKE2b-256 f060c20db3d0ec043dd0008a625be0ee7592fb3269f8cf7cb26cceeaa84d794f

See more details on using hashes here.

File details

Details for the file pump_fun_token_launcher-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pump_fun_token_launcher-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 419fee411bb235d0971f7896fc226b68cece63825d827153be0caedf8a91cfb4
MD5 2c0ebb65f9912072b8661723d1cdbb46
BLAKE2b-256 d0e39e1e1859f301f2059bfa8585af7a1e683beaaaaac6906485702968328583

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page