This workspace contains two copy-trading bots targeting BNB Chain (PancakeSwap + Four.meme):
BNB-Copytrading-Bot— TypeScript/Node.js implementation usingethersv6Rust-Copytrading-Bot— Rust implementation usingethers-rsand Tokio
Both listen to on-chain logs via WebSocket providers and mirror trades from configured target wallets using one or more copy wallets.
- DEX coverage: PancakeSwap swaps and Four.meme buy/sell events
- Target wallet filtering: Mirror only when initiator is in
TARGET_WALLETS - Multiple copy wallets: Comma-separated private keys
- Sizing controls: Scale by
COPY_PERCENT(TS) orCOPY_PERCENT/COPY_PERCENTS(Rust) - Gas controls: Minimum gas price and multiplier
- Fallback decoding: Pair-contract inspection when router calldata parsing fails (PancakeSwap)
Main/
BNB-Copytrading-Bot/ # TypeScript implementation
Rust-Copytrading-Bot/ # Rust implementation
README.md # This file
A unified, production-ready TypeScript bot that copy-trades target wallets across PancakeSwap and Four.meme on BNB Chain.
- Node.js 18+
- NPM 9+ (or pnpm/yarn)
- BSC WS + HTTP endpoints
cd BNB-Copytrading-Bot
npm installCreate BNB-Copytrading-Bot/.env:
# RPC endpoints
WS_URL=wss://bsc-mainnet.nodereal.io/ws/v1/XXXXX
BSC_RPC_URL=https://bsc-dataseed.binance.org
# Optional secondary endpoints
WS_URL_2=
BSC_RPC_URL_2=
# PancakeSwap core contracts
PANCAKE_SWAP_ROUTER_ADDR=0x10ED43C718714eb63d5aA57B78B54704E256024E
PANCAKE_SWAP_FACTORY_ADDR=0xCA143Ce32Fe78f1f7019d7d551a6402fC5350c73
# Four.meme contract
FOUR_MEME_ADDRESS=0xYourFourMemeContractAddress
# Copy-trading wallets (comma-separated private keys)
COPY_KEYS=0xabc...,0xdef...
# Target wallets to follow (comma-separated addresses, lowercase)
TARGET_WALLETS=0xwallet1,0xwallet2
# Sizing and risk controls
COPY_PERCENT=1.0
SLIPPAGE_BPS=300
GAS_MULTIPLIER=1.0
MIN_GAS_PRICE_GWEI=5# Dev (unified listener)
npm run dev
# Production (build + run)
npm start
# Dev per-DEX
npm run pancakeswap
npm run fourmeme- Unified listener subscribes to PancakeSwap
Swapand Four.memeTokenPurchase/TokenSaleevents - Fetches original tx to identify initiator and filter via
TARGET_WALLETS - Derives path/amount via router decode or pair fallback
- Executes via:
pancakeSwap/tradeExecutorOnPancakeswap.tsfourmeme/tradeExecutorOnFourmeme.ts
High-performance copy-trading bot written in Rust, built on ethers-rs and Tokio.
- Rust toolchain (stable) via rustup
- BSC WS + HTTP endpoints
cd Rust-Copytrading-Bot
cargo build --releaseCreate Rust-Copytrading-Bot/.env:
# RPC endpoints
WS_URL=wss://bsc.your-provider.example/ws
BSC_RPC_URL=https://bsc.your-provider.example
# Contracts
PANCAKE_SWAP_ROUTER_ADDR=0x10ED43C718714eb63d5aA57B78B54704E256024E
FOUR_MEME_ADDRESS=0xYourFourMemeContractAddress
# Wallets and copy settings
COPY_KEYS=0xabc...,0xdef...
TARGET_WALLETS=0xtrader1,0xtrader2
# Copy behavior
COPY_PERCENT=1.0
COPY_PERCENTS=1.0,0.5,2.0
SLIPPAGE_BPS=300
GAS_MULTIPLIER=1.0
MIN_GAS_PRICE_GWEI=5
GAS_LIMIT_OVERRIDE=400000cargo run --release- Subscribes to combined topic filter for PancakeSwap
Swapand Four.meme buy/sell - Validates initiator against
TARGET_WALLETSand excludes copy wallets - Infers trade params and executes via executors in
pancakeswap/andfourmeme/ - Supports per-wallet
COPY_PERCENTSwith fallback toCOPY_PERCENT
- Fund copy wallets with sufficient BNB for gas; Four.meme buys consume value + gas
- Use reliable WebSocket providers; outages will disrupt event flow
- For PancakeSwap native input, BNB→WBNB is detected and handled
- Approvals are automatic where needed; consider periodic allowance reviews
- This software sends real transactions from your wallets
- Start with small sizes; double-check all env vars and addresses
- Keep private keys secure; prefer dedicated wallets with limited funds
- Missing env errors: ensure
.envexists with required keys - No trades mirrored: verify
TARGET_WALLETSand that targets are active - Allowance/balance issues: ensure tokens/BNB and wait for approvals to confirm
- Router decode failures: pair fallback logic attempts to infer path/amount
- TypeScript bot: MIT
- Rust bot: MIT
- TypeScript:
ethersv6 - Rust:
ethers-rs+ Tokio