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.
- How it works
- Features
- Example
- Requirements
- Quick start
- Configuration
- Project structure
- How trades are detected
- Supported venues
- Logging
- Security
- Risks and disclaimer
- Troubleshooting
- Contact
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.
| 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 |
Target wallet
GXAtmWucJEQxuL8PtpP13atoFi78eM6c9Cuw9fK9W4na
Copy wallet
HqbQwVM2fhdYJXqFhBE68zX6mLqCWqEqdgrtf2ePmjRz
| Role | Transaction |
|---|---|
| Target | View on Solscan |
| Copied | View on Solscan |
- 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)
- A Solana HTTP RPC endpoint (
RPC_ENDPOINT) with good read performance - A Solana WebSocket RPC endpoint (
RPC_WEBSOCKET_ENDPOINT) that supportstransactionSubscribe(Helius and similar providers) - A funded copy wallet with enough SOL for swaps, ATA creation, and fees (plus Jito tips if enabled)
- Jito block-engine URL and tip stream URL for bundle-based submission
git clone https://github.com/<your-org>/Copy-trading-bot.git
cd Copy-trading-botcp .env.example .envEdit .env with your RPC URLs, target wallet, slippage, and Jito settings. See Configuration for every variable.
The bot loads the signing keypair from key.txt in the project root (Base58-encoded secret key, one line, no quotes):
your_base58_private_key_here
Never commit
key.txtor.env. Both are ignored by.gitignorefor.env; ensurekey.txtis also kept local-only.
cargo build --release
cargo run --releaseOn success you should see a startup log line similar to:
--------------------- Copy-trading-bot start!!! ------------------
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=...) |
RPC_WEBSOCKET_ENDPOINT |
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 |
RAY_AUTHORITY_V4 |
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%) |
JITO_TIP_VALUE |
If using Jito | Tip amount (lamports or configured unit per your setup) |
JITO_BLOCK_ENGINE_URL |
If using Jito | Jito block engine base URL |
JITO_TIP_STREAM_URL |
If using Jito | Jito tip stream URL for dynamic tip hints |
JITO_TIP_PERCENTILE |
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) |
- Signing key:
key.txt(Base58), read byimport_wallet()/import_arc_wallet()insrc/common/utils.rs .env: RPC endpoints, target wallet, DEX constants, slippage, and Jito — not the private key in the current codebase
For transactionSubscribe with rich transaction details, a provider such as Helius is typical. Use the HTTP URL for RPC_ENDPOINT and the Geyser/WebSocket URL for RPC_WEBSOCKET_ENDPOINT.
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 pump_swap / raydium_swap entry points
│ └── services/
│ └── jito.rs # Jito tip accounts, bundle status, progress UI
└── README.md
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
Incoming messages are routed to:
tx_ray— Raydium swap detection andswap_to_events_on_raydiumtx_pump— Pump.fun buy/sell detection andswap_to_events_on_pump
Trade size can be scaled (e.g. amount_in * percent / 100) before calling the engine layer.
- Program:
6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P - Buy/sell via bonding-curve accounts and associated PDAs
- Implementation:
src/dex/pump.rs, orchestrated byengine::swap::pump_swap
- AMM program:
675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 - Pool discovery via on-chain filters and Raydium API v3 (
get_pool_info) - Implementation:
src/dex/raydium.rs, orchestrated byengine::swap::raydium_swap
swap_on_jup in main.rs is reserved for Jupiter-based routing when needed.
Runtime messages are appended to src/log.txt with timestamps via log_message() in src/common/utils.rs.
- 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.
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.
| Issue | What to try |
|---|---|
link.exe not found (Windows) |
Install Visual Studio Build Tools with C++ workload |
| WebSocket connection fails | Verify RPC_WEBSOCKET_ENDPOINT 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 (UNIT_PRICE / UNIT_LIMIT), use a faster RPC |
| 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 |
For full bot setups, integrations, or custom development:
Telegram: @RRR
If this project helps you, please star the repository.