A high-performance Solana copy-trading bot written in Rust. It watches a target wallet’s on-chain activity and mirrors trades on Raydium and Pump.fun as soon as matching transactions appear.
Solana Copy Trading Bot
A high-performance Solana copy-trading bot written in Rust. It watches a target wallet’s on-chain activity and mirrors trades on Raydium and Pump.fun as soon as matching transactions appear.
The bot uses WebSocket transaction streaming (Helius-style transactionSubscribe) for low-latency detection and can submit copies via Jito bundles for faster inclusion.
Table of contents
- How it works
- Features
- Example
- Requirements
- Quick start
- Configuration
- Project structure
- How trades are detected
- Supported venues
- Logging
- Security
- Risks and disclaimer
- Troubleshooting
- Contact
How it works
flowchart LR
A[Target wallet trades] --> B[Solana RPC WebSocket]
B --> C[Bot filters Raydium / Pump.fun txs]
C --> D[Parse direction, mint, amount]
D --> E[Build swap on your wallet]
E --> F[Sign and send via RPC / Jito]
- Subscribe — Connect to an RPC WebSocket endpoint that supports
transactionSubscribe(e.g. Helius). - Filter — Only transactions that touch Raydium AMM or Pump.fun program accounts are considered.
- Parse — Extract trade direction (buy/sell), token mint, size, and pool metadata from the target’s transaction.
- Mirror — Execute a proportional swap from your wallet using the same venue (Raydium or Pump.fun).
- Submit — Broadcast the signed transaction; optionally route through Jito block-engine bundles for priority landing.
Features
| Feature | Description | |--------|-------------| | Real-time streaming | WebSocket transactionSubscribe with processed commitment for early detection | | Multi-DEX | Raydium AMM swaps and Pump.fun buy/sell | | Target filtering | Monitors a configurable TARGET_PUBKEY | | Noise reduction | Excludes known aggregator/program accounts (e.g. Jupiter) via accountExclude | | Jito integration | Optional bundle submission and tip configuration for competitive landing | | Structured modules | Separate dex, engine, core, and services layers for maintainability |
Example
Target wallet
GXAtmWucJEQxuL8PtpP13atoFi78eM6c9Cuw9fK9W4na
Copy wallet
HqbQwVM2fhdYJXqFhBE68zX6mLqCWqEqdgrtf2ePmjRz
| Role | Transaction | |------|-------------| | Target | View on Solscan | | Copied | View on Solscan |
Requirements
Software
- Rust 1.70+ (edition 2021)
- Windows: Visual Studio Build Tools with the Desktop development with C++ workload (provides
link.exefor native dependencies) - Linux / macOS: standard build tools (
build-essential, Xcode CLI tools)
Solana / RPC
- A Solana HTTP RPC endpoint (
RPC_ENDPOINT) with good read performance - A Solana WebSocket RPC endpoint (
RPCWEBSOCKETENDPOINT) that supportstransactionSubscribe(Helius and similar providers) - A funded copy wallet with enough SOL for swaps, ATA creation, and fees (plus Jito tips if enabled)
Optional
- Jito block-engine URL and tip stream URL for bundle-based submission
Quick start
1. Clone the repository
git clone https://github.com/<your-org>/Copy-trading-bot.git
cd Copy-trading-bot
2. Configure environment
cp .env.example .env
Edit .env with your RPC URLs, target wallet, slippage, and Jito settings. See Configuration for every variable.
3. Add your wallet key
The bot loads the signing keypair from key.txt in the project root (Base58-encoded secret key, one line, no quotes):
yourbase58privatekeyhere
Never commitkey.txtor.env. Both are ignored by.gitignorefor.env; ensurekey.txtis also kept local-only.
4. Build and run
cargo build --release
cargo run --release
On success you should see a startup log line similar to:
--------------------- Copy-trading-bot start!!! ------------------
Configuration
Copy .env.example to .env and set the values below.
| Variable | Required | Description | |----------|----------|-------------| | RPC_ENDPOINT | Yes | HTTP Solana RPC URL (e.g. https://mainnet.helius-rpc.com/?api-key=...) | | RPCWEBSOCKETENDPOINT | Yes | WebSocket URL for transactionSubscribe | | TARGET_PUBKEY | Yes | Public key of the wallet whose trades you want to copy | | JUP_PUBKEY | Yes | Account to exclude from the subscription filter (commonly your Jupiter-related pubkey) | | RAY_PUBKEY | Yes | Raydium-related pubkey used in parsing/filtering | | SOL_PUBKEY | Yes | Wrapped SOL / native mint reference for routing | | RAYAUTHORITYV4 | Yes | Raydium authority v4 address for swap instruction building | | WSOL_USDC | Yes | Reference pool or mint pair for WSOL/USDC lookups | | SLIPPAGE | Yes | Slippage tolerance in basis points (e.g. 100 = 1%) | | JITOTIPVALUE | If using Jito | Tip amount (lamports or configured unit per your setup) | | JITOBLOCKENGINE_URL | If using Jito | Jito block engine base URL | | JITOTIPSTREAM_URL | If using Jito | Jito tip stream URL for dynamic tip hints | | JITOTIPPERCENTILE | Optional | Tip percentile when using tip stream (see services/jito.rs) | | UNIT_PRICE | Optional | Priority fee unit price (default 1) | | UNIT_LIMIT | Optional | Compute unit limit (default 300000) |
Wallet vs .env
- Signing key:
key.txt(Base58), read byimportwallet()/importarc_wallet()insrc/common/utils.rs .env: RPC endpoints, target wallet, DEX constants, slippage, and Jito — not the private key in the current codebase
Recommended RPC provider
For transactionSubscribe with rich transaction details, a provider such as Helius is typical. Use the HTTP URL for RPCENDPOINT and the Geyser/WebSocket URL for RPCWEBSOCKET_ENDPOINT.
Project structure
Copy-trading-bot/
├── Cargo.toml # Dependencies (Solana SDK, Raydium, Jito, tokio, etc.)
├── .env.example # Environment template
├── key.txt # Your wallet secret (create locally, do not commit)
├── src/
│ ├── main.rs # WebSocket subscription loop and trade handlers
│ ├── lib.rs # Module exports
│ ├── common/
│ │ └── utils.rs # RPC clients, wallet, logging, AppState
│ ├── core/
│ │ ├── token.rs # SPL token / ATA helpers
│ │ └── tx.rs # Sign, send, Jito bundle confirmation
│ ├── dex/
│ │ ├── pump.rs # Pump.fun program constants and swap logic
│ │ └── raydium.rs # Raydium AMM swap and pool discovery
│ ├── engine/
│ │ └── swap.rs # High-level pumpswap / raydiumswap entry points
│ └── services/
│ └── jito.rs # Jito tip accounts, bundle status, progress UI
└── README.md
How trades are detected
The bot subscribes with a JSON-RPC payload similar to:
- Method:
transactionSubscribe - Filter:
accountInclude— Raydium AMM program675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8and Pump.fun program6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P - Exclude:
accountExclude— value fromJUP_PUBKEYto reduce unrelated aggregator traffic - Commitment:
processed - Encoding:
jsonParsedwith full transaction details
txray— Raydium swap detection andswaptoeventson_raydiumtxpump— Pump.fun buy/sell detection andswaptoeventson_pump
amount_in * percent / 100) before calling the engine layer.
Supported venues
Pump.fun
- Program:
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P - Buy/sell via bonding-curve accounts and associated PDAs
- Implementation:
src/dex/pump.rs, orchestrated byengine::swap::pump_swap
Raydium
- AMM program:
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 - Pool discovery via on-chain filters and Raydium API v3 (
getpool_info) - Implementation:
src/dex/raydium.rs, orchestrated byengine::swap::raydium_swap
Jupiter (planned / stub)
swaponjup in main.rs is reserved for Jupiter-based routing when needed.
Logging
Runtime messages are appended to src/log.txt with timestamps via log_message() in src/common/utils.rs.
Security
- Private keys — Store only on the machine that runs the bot. Prefer a dedicated hot wallet with limited funds.
.envandkey.txt— Must not be pushed to GitHub or shared in chat.- RPC API keys — Treat URLs with embedded keys as secrets; rotate if leaked.
- Target wallet — Copying a wallet you do not control is legal/technical risk; verify the address carefully.
Risks and disclaimer
Copy trading on Solana involves substantial financial risk: slippage, failed transactions, MEV, illiquid tokens, and total loss of funds are possible. This software is provided as-is with no guarantee of profitability, correctness, or uptime. Use at your own risk. Nothing here is financial advice.
Troubleshooting
| Issue | What to try | |-------|-------------| | link.exe not found (Windows) | Install Visual Studio Build Tools with C++ workload | | WebSocket connection fails | Verify RPCWEBSOCKETENDPOINT and provider supports transactionSubscribe | | TARGET_PUBKEY not set | Ensure .env is in the project root and loaded (dotenv in main.rs) | | Not set Private Key / wallet errors | Create key.txt with a valid Base58 secret key | | Trades not copying | Confirm target actually uses Raydium/Pump.fun; check logs in src/log.txt | | Slow or dropped txs | Enable Jito tips, raise priority fees (UNITPRICE / UNITLIMIT), use a faster RPC |
Tech stack
| Layer | Technology | |-------|------------| | Language | Rust (2021 edition) | | Async runtime | Tokio | | Solana | solana-sdk, solana-client 1.16.x | | DEX | Raydium AMM (raydium-amm, raydium-library), Pump.fun on-chain program | | Streaming | tokio-tungstenite WebSocket client | | Bundles | Jito JSON-RPC block engine client | | Config | dotenv, environment variables |
Contact
For full bot setups, integrations, or custom development:
Telegram: @soulcrancerdev
FAQ
Is this financial advice?
No. This project is for educational purposes only. Use at your own risk.
Can I fork and modify this?
Yes. MIT licensed — fork, modify, and contribute via pull requests.
Disclaimer
Not financial advice. Trading and software use involves risk. Past performance does not guarantee future results.
Keywords: high-performance Solana copy-trading bot written in Rust, copy-trading, copytrade-bot, solana, solana-bot, trading-bot