A collection of Rust examples, SDKs, and tools for building high-performance Solana trading bots. Includes trading examples, SDKs for DEX integration, transaction parsing, key management, and real-time streaming.
中文 | English | Website | Telegram | Discord
☕ Support This Project
This SDK is completely free and open source. However, maintaining and continuously updating it requires significant AI computing resources and token consumption. If this SDK helps with your development, consider making a monthly SOL donation — any amount is appreciated and helps keep this project alive!
Donation Wallet:
6oW7AXz1yRb57pYSxysuXnMs2aR1ha5rzGzReZ1MjPV8
- ✨ Features
- 📁 Project Structure
- 🛠️ Examples
- 📎 Example README index
- 📦 SDKs & Tools
- 📋 Before you run & privacy
- 🚀 Quick Start
- 📄 License
- 💬 Contact
- Trading Examples: Ready-to-use bots for PumpSwap (outer pool) and PumpFun (bonding curve) with automated buy/sell
- Multiple SWQoS Support: Concurrent transaction submission via multiple MEV protection services
- Comprehensive SDKs: Modular SDKs for trading, parsing, key management, and streaming
- Real-time Streaming: gRPC-based transaction streaming and parsing with low-latency event processing
- Secure Key Management: Encrypted keystore support with password protection
- Production Ready: Optimized builds with cross-platform support (Linux, macOS)
fnzero-examples/
├── pumpswap_trade/ # PumpSwap (outer pool) trading example (direct private key)
├── pumpswap_trade_with_safekey/ # PumpSwap (outer pool) trading example (encrypted keystore)
├── pumpfun_trade/ # PumpFun (bonding curve) trading example (direct private key)
├── pumpfun_trade_with_safekey/ # PumpFun (bonding curve) trading example (encrypted keystore)
├── pumpfun_grpc_sniper/ # PumpFun gRPC sniper example (direct private key)
├── pumpfun_shredstream_sniper/ # PumpFun ShredStream sniper example (direct private key)
├── sol-trade-sdk/ # Unified DEX trading SDK
├── sol-parser-sdk/ # Transaction parsing SDK (gRPC streaming)
├── sol-safekey/ # Encrypted key management library
└── solana-streamer/ # Solana transaction streaming utilities
| Example | Description | Run Command | Source Code |
|---|---|---|---|
| PumpSwap Trading | Automated buy→wait→sell loop on PumpSwap (outer AMM); configurable rounds and rest | ./run.sh |
pumpswap_trade |
| PumpSwap Trading (Encrypted) | Same as above with encrypted keystore | ./run.sh |
pumpswap_trade_with_safekey |
| PumpFun Trading | Buy→wait→sell on PumpFun bonding curve; token must not have graduated to PumpSwap | ./run.sh |
pumpfun_trade |
| PumpFun Trading (Encrypted) | Same as above; keystore / KEYPAIR_BASE58 |
./run.sh |
pumpfun_trade_with_safekey |
| PumpFun gRPC Sniper | Monitor creator first buys through sol-parser-sdk gRPC, buy once, auto-sell after 3s |
./run.sh |
pumpfun_grpc_sniper |
| PumpFun ShredStream Sniper | Monitor creator first buys through sol-parser-sdk ShredStream, buy once, auto-sell after 3s |
./run.sh |
pumpfun_shredstream_sniper |
| Scenario | Directory |
|---|---|
| Token still on PumpFun bonding curve (not graduated to PumpSwap) | pumpfun_trade or pumpfun_trade_with_safekey |
| Token on PumpSwap outer AMM | pumpswap_trade or pumpswap_trade_with_safekey |
Private key via PRIVATE_KEY or private_key in YAML |
pumpfun_trade / pumpswap_trade |
Encrypted keystore + password (or fallback KEYPAIR_BASE58) |
pumpfun_trade_with_safekey / pumpswap_trade_with_safekey |
| Snipe new PumpFun tokens from a gRPC trade stream | pumpfun_grpc_sniper |
| Snipe new PumpFun tokens from ShredStream outer instructions | pumpfun_shredstream_sniper |
- ✅ Flow: Buy → wait ~30s → sell; 1 round by default (change
ROUNDS/REST_SECSin each crate’ssrc/run.rs) - ✅ Multi-SWQoS: Concurrent submission to several MEV channels
- ✅ YAML +
.env:config/dev|prod/solana.yaml,trading.yaml, and env overrides - ✅ Durable nonce: Required when 2+ SWQoS providers are enabled—set
nonce_configorNONCE_ACCOUNT; empty""placeholders in YAML are skipped soNONCE_ACCOUNTstill works - ✅ Gas / slippage: Configurable in
trading.yaml - ✅ Default:
wait_tx_confirmed: false; the bot waits a fixed interval after buy before reading balance—tune for production if needed ⚠️ Sell size: Each round sells the wallet’s full token balance for that mint (including any balance you held before the buy)
| Example | Chinese | English |
|---|---|---|
| PumpSwap (private key) | README_CN.md | README.md |
| PumpSwap (encrypted) | README_CN.md | README.md |
| PumpFun (private key) | README_CN.md | README.md |
| PumpFun (encrypted) | README_CN.md | README.md |
| PumpFun gRPC sniper | README_CN.md | README.md |
| PumpFun ShredStream sniper | README_CN.md | README.md |
- The repo only ships
*.yaml.exampleand.env.example. Your localsolana.yaml,trading.yaml, and.envare created from those templates and are git-ignored (see “Before you run & privacy”). - Environment variables can override YAML. With multiple SWQoS providers, configure durable nonce or
NONCE_ACCOUNT.
| Service | Transport Protocols |
|---|---|
| Astralane | HTTP, QUIC ⚡ |
| BlockRazor | HTTP, gRPC |
| Bloxroute | HTTP |
| FlashBlock | HTTP |
| Jito | HTTP |
| NextBlock | HTTP |
| Node1 | HTTP, QUIC ⚡ |
| Soyas | QUIC ⚡ |
| Speedlanding | QUIC ⚡ |
| Stellium | HTTP |
| Temporal | HTTP |
| ZeroSlot | HTTP |
| Default | RPC |
API Key Application: Apply for API keys through the official website: https://fnzero.dev/swqos
Note: ⚡ = QUIC (Quick UDP Internet Connections) provides lower latency compared to HTTP/gRPC. Services using QUIC (Astralane, Node1, Soyas, Speedlanding) typically offer the best transaction submission performance.
Comprehensive Rust SDK for Solana DEX trading with unified interface for multiple protocols.
Features:
- Support for PumpFun, PumpSwap, Bonk, Raydium CPMM, Raydium AMM V4, Meteora DAMM V2
- Multiple MEV protection services (Jito, BlockRazor, Astralane, etc.)
- Middleware system for custom instruction modification
- Shared infrastructure for multi-wallet scenarios
- Address Lookup Table (ALT) support
- Durable Nonce management
- Gas fee strategy optimization
Documentation: sol-trade-sdk/README.md
Transaction parsing SDK with gRPC streaming support for real-time event processing.
Features:
- Parse PumpFun, PumpSwap, Raydium, and other DEX transactions
- gRPC-based streaming for low-latency event processing
- Event filtering and transformation
- Trade event extraction
- Account filler for optimized account lookups
Documentation: sol-parser-sdk/README.md
Encrypted key management library for secure Solana keypair storage.
Features:
- Encrypt/decrypt Solana keypairs with password protection
- JSON-based keystore format
- Base58 private key support
- CLI tools for key management
- Integration with trading examples
Documentation: sol-safekey/README.md
Utilities for Solana transaction streaming and real-time data processing.
Features:
- Shred stream subscription
- Transaction streaming
- Event processing pipeline
- Performance-optimized parsing
Documentation: solana-streamer/README.md
Do this before running any trading example for the first time. This repository does not ship your private keys, SWQoS API tokens, or production RPC URLs—only *.yaml.example and .env.example templates.
git clone https://github.com/0xfnzero/fnzero-examples.git
cd fnzero-examplescd into the example you need (pumpswap_trade, pumpfun_trade, etc.) and copy templates per environment:
cd pumpswap_trade # or pumpfun_trade / *_with_safekey
cp .env.example .env
cp config/dev/solana.yaml.example config/dev/solana.yaml
cp config/dev/trading.yaml.example config/dev/trading.yaml
# For prod, also copy config/prod/*.example → config/prod/*.yamlpumpfun_grpc_sniper and pumpfun_shredstream_sniper only use .env, no YAML:
cd pumpfun_grpc_sniper # or pumpfun_shredstream_sniper
cp .env.example .envThen edit locally (do not commit; sniper examples only need .env):
| File | What to fill in |
|---|---|
.env |
PRIVATE_KEY or KEYSTORE_PASSWORD, SOLANA_RPC_URL, NONCE_ACCOUNT (if multi-SWQoS), … |
config/*/solana.yaml |
rpc_url, private_key or keystore_path, SWQoS api_token, nonce_config, … |
config/*/trading.yaml |
Buy size, slippage, gas, … |
APP_ENV=dev uses config/dev/, APP_ENV=prod uses config/prod/.
This repo’s .gitignore excludes the sol-safekey tree. Clone that project to generate keystore.json:
cd /path/to/parent
git clone https://github.com/0xfnzero/sol-safekey.git
cd sol-safekey
cargo run --release -- export <private_key_or_mnemonic> /path/to/fnzero-examples/pumpswap_trade_with_safekey/keystore.jsonThen set keystore_path in the example’s solana.yaml (e.g. ./keystore.json).
These paths are ignored by .gitignore—do not force-add them:
.env,.env.*(except.env.example)config/**/solana.yaml,config/**/trading.yaml(your local copies)keystore.jsonand any file containing private keys
Run git status before pushing. If secrets were ever committed, rotate keys and scrub history.
- Rust 1.70+ and Cargo
- Solana CLI (optional)
- A reliable Solana RPC endpoint (prefer your own or paid; public RPCs rate-limit)
Run commands inside the example crate directory (each folder is its own Cargo package; there is no repo-root workspace). If you have not completed the steps above, copy templates and edit them first.
Option 1: Private key (PumpSwap or PumpFun)
cd pumpswap_trade # outer AMM; use cd pumpfun_trade for bonding-curve tokens
cp .env.example .env
cp config/dev/solana.yaml.example config/dev/solana.yaml
cp config/dev/trading.yaml.example config/dev/trading.yaml
# Edit .env and yaml: PRIVATE_KEY, RPC, SWQoS tokens, nonce, … (see “Before you run”)
./run.sh <TOKEN_MINT_ADDRESS>
# or: cargo run --release -- <TOKEN_MINT_ADDRESS>Option 2: Encrypted keystore (requires a separate sol-safekey clone as described above)
cd /path/to/sol-safekey
cargo run --release -- export <private_key_or_mnemonic> /path/to/fnzero-examples/pumpswap_trade_with_safekey/keystore.json
cd /path/to/fnzero-examples/pumpswap_trade_with_safekey # or pumpfun_trade_with_safekey
cp .env.example .env
cp config/dev/solana.yaml.example config/dev/solana.yaml
cp config/dev/trading.yaml.example config/dev/trading.yaml
# Edit solana.yaml: keystore_path, SWQoS, nonce, …
./run.sh <TOKEN_MINT_ADDRESS># Environment: dev or prod
APP_ENV=dev
# Token mint address to trade
MINT=your_token_mint_address
# Sol amount to buy (SOL)
BUY_SOL_AMOUNT=0.01
# RPC URL
SOLANA_RPC_URL=https://your-rpc-endpoint.com
# Keystore password (for encrypted key)
KEYSTORE_PASSWORD=your_password
# Durable nonce account (required for multiple SWQoS)
NONCE_ACCOUNT=your_nonce_account_addressswqos:
region: "Frankfurt" # or NewYork, Tokyo, etc.
enabled_providers:
- provider: "Astralane"
api_token: "your_token"
enabled: true
- provider: "BlockRazor"
api_token: "your_token"
enabled: true
# Add more providers as neededEach example uses .cargo/config.toml so artifacts go to build-cache/release/ (not the default target/release/).
cd pumpswap_trade # or pumpfun_trade, pumpswap_trade_with_safekey, pumpfun_trade_with_safekey
cargo build --release
./build-cache/release/pumpswap_trade_with_safekey <TOKEN_MINT_ADDRESS>
# macOS → Linux bundle (requires x86_64-unknown-linux-gnu toolchain)
./build-linux-release.sh # produces linux-release/deploy.tar.gzMIT License
See LICENSE for details.
- Official Website: https://fnzero.dev/
- Project Repository: https://github.com/0xfnzero/fnzero-examples
- Telegram Group: https://t.me/fnzero_group
- Discord Server: https://discord.gg/vuazbGkqQE
- Security: Never commit private keys, keystores, local
solana.yaml/trading.yaml, or.env; read “Before you run & privacy” before the first run - Testing: Thoroughly test on devnet before using on mainnet
- Risk: Trading cryptocurrencies involves significant risk
- Compliance: Ensure compliance with local laws and regulations
- RPC Limits: Monitor RPC usage to avoid rate limiting
- MEV Services: Configure API tokens properly for MEV protection services
Contributions are welcome! Please feel free to submit a Pull Request.