Rust example: automated buy → wait ~30s → sell on PumpSwap outer AMM (1 round by default; edit src/run.rs). Multiple SWQoS channels.
中文 | English | Website | Telegram | Discord
Note: If the token is still on PumpFun (bonding curve, not graduated), use
pumpfun_trade/pumpfun_trade_with_safekeyin this repo instead.
- Automated Trading Loop: Buy → wait ~30s → sell; 1 round by default (edit
ROUNDS,REST_SECSinsrc/run.rs) - Multiple SWQoS Support: Send transactions concurrently to multiple MEV protection services
- Durable Nonce: Transaction replay protection for multi-SWQoS scenarios
- Flexible Configuration: Support for both YAML config files and environment variables
- Environment Priority: Environment variables override config file settings for sensitive data
- Cross-Platform Build: Build scripts for Linux deployment
git clone https://github.com/0xfnzero/fnzero-examples.git
cd fnzero-examples/pumpswap_tradeEnsure you have Rust and Cargo installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThe repo does not track your .env, config/**/solana.yaml, or config/**/trading.yaml (see root README.md “Before you run & privacy”). On first use:
cp .env.example .env
cp config/dev/solana.yaml.example config/dev/solana.yaml
cp config/dev/trading.yaml.example config/dev/trading.yamlEdit those files with keys, RPC, SWQoS tokens—never git add them.
Create a .env file based on .env.example:
# Environment: dev or prod
APP_ENV=prod
# Token mint address (can also be passed as CLI argument)
MINT=
# Wallet private key (supports base58 or standard 64-byte array JSON format)
PRIVATE_KEY=
# RPC URL
SOLANA_RPC_URL=http://your-rpc-endpoint.com
# Buy amount in SOL
BUY_SOL_AMOUNT=0.01
# SWQoS region
SWQOS_REGION=Frankfurt
# SWQoS provider tokens
SWQOS_ASTRALANE_TOKEN=
SWQOS_BLOCKRAZOR_TOKEN=
SWQOS_JITO_TOKEN=
SWQOS_ZEROSLOT_TOKEN=
# ... etc.
# Durable nonce account (required when using 2+ SWQoS)
NONCE_ACCOUNT=This project supports direct private key configuration. You can configure your wallet in two ways:
- Copy
.env.exampleto.env - Add your private key to the
PRIVATE_KEYvariable
cp .env.example .envEdit .env:
PRIVATE_KEY=your_private_key_herePrivate Key Format Support:
- Base58 format: Your standard Solana private key string (e.g., from
solana-keygen new) - 64-byte array JSON:
[1,2,3,...64]format exported from some wallets
You can also set the private key directly in the config file:
# config/dev/solana.yaml or config/prod/solana.yaml
private_key: "your_private_key_here"Security Notes:
- Never commit
.envfiles to version control - Use environment variables in production for better security
- Keep your private key safe and never share it
Keep local config (copied from *.example, not committed) under config/:
config/
├── dev/
│ ├── solana.yaml # local: RPC, private_key, SWQoS, nonce
│ └── trading.yaml # local: trading params, gas
└── prod/
├── solana.yaml
└── trading.yaml
Only *.yaml.example templates live in the repository.
Environment Variables Override:
- All sensitive values in config files can be overridden by environment variables
.envvalues have higher priority than config files- Useful for keeping secrets out of version control
The following SWQoS services are supported:
| Service | Required Param |
|---|---|
| Astralane | API Key |
| BlockRazor | API Key |
| Jito | UUID |
| NextBlock | API Key |
| Bloxroute | API Key |
| ZeroSlot | API Key |
| Temporal | API Key |
| FlashBlock | API Key |
| Node1 | API Key |
Apply for API keys at: https://fnzero.dev/swqos
Simply run the script:
./run.shThe script will:
- Load configuration from
.envandconfig/dev/solana.yaml - Build and run the trading bot in release mode
- Support dev/prod environments via
APP_ENVvariable
./pumpswap_trade <MINT_ADDRESS>MINT=<MINT_ADDRESS> ./pumpswap_trade# Set MINT in .env or pass as argument
./pumpswap_tradeAPP_ENV=prod ./pumpswap_trade <MINT_ADDRESS>cargo build --releaseThis crate sets target-dir = "build-cache" in .cargo/config.toml; the binary is at build-cache/release/pumpswap_trade
./build-linux-release.shThis script:
- Cross-compiles for Linux (x86_64-unknown-linux-gnu)
- Packages binary and configs into
linux-release/deploy.tar.gz
Output:
linux-release/
├── x86_64-unknown-linux-gnu/release/pumpswap_trade
└── deploy.tar.gz
MIT License
- Official Website: https://fnzero.dev/
- Project Repository: https://github.com/0xfnzero/fnzero-examples
- Telegram Group: https://t.me/fnzero_group
- Discord: https://discord.gg/vuazbGkqQE