A professional copy trading bot for BNB Chain supporting both PancakeSwap and Four.meme DEX platforms. Available in TypeScript and Rust implementations.
rec1.mp4
If you have any questino or feedback, contact me via telegram or whatsapp - (+44 7832607596)
- Overview
- Features
- Architecture
- Quick Start
- TypeScript Bot Setup
- Rust Bot Setup
- Configuration
- Usage
- Security Considerations
- Troubleshooting
- Contributing
- License
This bot monitors target wallets on BNB Chain and automatically mirrors their trades on PancakeSwap and Four.meme. It supports multiple copy wallets with configurable sizing, slippage, and gas controls.
- Multi-DEX Support: Trade on PancakeSwap (v2) and Four.meme
- Real-time Monitoring: WebSocket-based event listening
- Target Wallet Filtering: Only mirror trades from whitelisted wallets
- Multiple Copy Wallets: Execute trades across multiple wallets simultaneously
- Configurable Sizing: Adjust trade sizes by percentage
- Gas Optimization: Smart gas price management
- Error Handling: Robust error handling and retry logic
- β WebSocket event subscription for real-time trading
- β Automatic trade detection and execution
- β Multi-wallet support with individual settings
- β PancakeSwap router integration (v2)
- β Four.meme contract integration
- β Automatic token approvals
- β Slippage protection
- β Gas price management
- β Comprehensive logging
- β Error recovery and retry mechanisms
PancakeSwap:
- Token swaps (any pair)
- Native BNB swaps (handles WBNB conversion)
Four.meme:
- Token purchase
- Token sale
BNB-Copy-Trading-Bot/
βββ typescript-bot/ # TypeScript implementation
β βββ src/
β β βββ core/ # Core bot logic
β β βββ pancakeswap/ # PancakeSwap integration
β β βββ fourmeme/ # Four.meme integration
β β βββ utils/ # Utilities
β β βββ types/ # TypeScript types
β βββ tests/ # Test suite
β βββ package.json
β βββ tsconfig.json
βββ rust-bot/ # Rust implementation
β βββ src/
β β βββ core/ # Core bot logic
β β βββ pancakeswap/ # PancakeSwap integration
β β βββ fourmeme/ # Four.meme integration
β β βββ utils/ # Utilities
β β βββ types/ # Rust types
β βββ tests/ # Test suite
β βββ Cargo.toml
βββ .env.example # Environment configuration template
βββ README.md # This file
- Node.js 18+ (for TypeScript bot)
- Rust 1.70+ (for Rust bot)
- BNB Chain RPC endpoints (WebSocket + HTTP)
- Wallets funded with BNB for gas
TypeScript Bot:
cd typescript-bot
npm installRust Bot:
cd rust-bot
cargo build --releaseCreate a .env file in the typescript-bot directory:
# RPC Endpoints
WS_URL=wss://bsc-mainnet.nodereal.io/ws/v1/YOUR_API_KEY
BSC_RPC_URL=https://bsc-mainnet.nodereal.io/v1/YOUR_API_KEY
# Optional Fallback Endpoints
WS_URL_2=wss://bsc-dataseed.binance.org
BSC_RPC_URL_2=https://bsc-dataseed1.binance.org
# PancakeSwap Contracts
PANCAKE_SWAP_ROUTER_ADDR=0x10ED43C718714eb63d5aA57B78B54704E256024E
PANCAKE_SWAP_FACTORY_ADDR=0xCA143Ce32Fe78f1f7019d7d551a6402fC5350c73
# Four.meme Contract
FOUR_MEME_ADDRESS=0xYourFourMemeContractAddress
# Copy Wallets (comma-separated private keys)
COPY_KEYS=0xYourPrivateKey1,0xYourPrivateKey2
# Target Wallets to Follow (comma-separated addresses, lowercase)
TARGET_WALLETS=0xTargetWallet1,0xTargetWallet2
# Trading Parameters
COPY_PERCENT=1.0 # Copy 100% of trade size (1.0 = 100%)
SLIPPAGE_BPS=300 # 3% slippage tolerance
GAS_MULTIPLIER=1.0 # Gas price multiplier
MIN_GAS_PRICE_GWEI=5 # Minimum gas price
# Advanced Settings
ENABLE_PANCAKESWAP=true
ENABLE_FOURMEME=true
LOG_LEVEL=info# Development mode
npm run dev
# Production mode
npm start
# Run specific DEX only
npm run pancakeswap
npm run fourmemeCreate a .env file in the rust-bot directory:
# RPC Endpoints
WS_URL=wss://bsc-mainnet.nodereal.io/ws/v1/YOUR_API_KEY
BSC_RPC_URL=https://bsc-mainnet.nodereal.io/v1/YOUR_API_KEY
# Contracts
PANCAKE_SWAP_ROUTER_ADDR=0x10ED43C718714eb63d5aA57B78B54704E256024E
FOUR_MEME_ADDRESS=0xYourFourMemeContractAddress
# Wallets
COPY_KEYS=0xYourPrivateKey1,0xYourPrivateKey2
TARGET_WALLETS=0xTargetWallet1,0xTargetWallet2
# Trading Parameters
COPY_PERCENT=1.0
COPY_PERCENTS=1.0,0.5,2.0 # Per-wallet copy percentages
SLIPPAGE_BPS=300
GAS_MULTIPLIER=1.0
MIN_GAS_PRICE_GWEI=5
GAS_LIMIT_OVERRIDE=400000# Development mode
cargo run
# Release mode (optimized)
cargo run --release
# Run with specific log level
RUST_LOG=info cargo run --release| Variable | Description | Default | Required |
|---|---|---|---|
WS_URL |
WebSocket RPC URL | - | Yes |
BSC_RPC_URL |
HTTP RPC URL | - | Yes |
PANCAKE_SWAP_ROUTER_ADDR |
PancakeSwap router address | - | Yes |
FOUR_MEME_ADDRESS |
Four.meme contract address | - | Yes |
COPY_KEYS |
Private keys (comma-separated) | - | Yes |
TARGET_WALLETS |
Target wallet addresses | - | Yes |
COPY_PERCENT |
Copy size percentage | 1.0 | Yes |
SLIPPAGE_BPS |
Slippage in basis points | 300 | No |
GAS_MULTIPLIER |
Gas price multiplier | 1.0 | No |
MIN_GAS_PRICE_GWEI |
Minimum gas price (Gwei) | 5 | No |
COPY_PERCENT: Multiplier for trade size
1.0= 100% (same size)0.5= 50% (half size)2.0= 200% (double size)
SLIPPAGE_BPS: Maximum acceptable slippage
300= 3% slippage100= 1% slippage500= 5% slippage
- Configure your environment: Edit
.envwith your settings - Fund your copy wallets: Ensure sufficient BNB for gas
- Start the bot: Run
npm start(TS) orcargo run --release(Rust) - Monitor logs: Watch for trade executions in the console
COPY_PERCENTS=1.0,0.5,2.0This sets 100%, 50%, and 200% copy sizes for the three wallets respectively.
GAS_MULTIPLIER=1.5 # Use 1.5x current gas price
MIN_GAS_PRICE_GWEI=10 # Never go below 10 GweiEnable/disable specific DEXs:
ENABLE_PANCAKESWAP=true
ENABLE_FOURMEME=false- Test on testnet first
- Start with small amounts
- Monitor all transactions
- Keep private keys secure
- Use dedicated wallets: Never use your main wallet
- Limit funding: Only fund wallets with what you're willing to lose
- Monitor regularly: Check bot status frequently
- Secure environment: Keep
.envfiles secure and never commit them - Reliable RPC: Use premium RPC providers for stability
- Regular backups: Backup your configuration and wallet files
- Never share your private keys
- Use environment variables for keys
- Consider using hardware wallets for larger amounts
- Rotate keys regularly
No trades being mirrored:
- Verify
TARGET_WALLETScontains correct addresses (lowercase) - Check that target wallets are actively trading
- Ensure WebSocket connection is stable
Allowance errors:
- Bot automatically handles approvals
- Wait for approval transactions to confirm
- Check wallet has sufficient token balance
Router decode failures:
- Bot uses fallback methods to decode trades
- Check PancakeSwap router address is correct
- Verify pair contract exists
Gas estimation failures:
- Increase
GAS_LIMIT_OVERRIDEif set - Check wallet has sufficient BNB for gas
- Verify token contracts are valid
WebSocket disconnections:
- Use reliable RPC providers
- Configure fallback endpoints
- Monitor connection status
Enable verbose logging:
TypeScript:
LOG_LEVEL=debug npm startRust:
RUST_LOG=debug cargo run --releaseerror: Only errorswarn: Warnings and errorsinfo: General information (default)debug: Detailed debug information
- Connection status
- Trade execution success rate
- Gas prices
- Wallet balances
- Error rates
TypeScript:
npm testRust:
cargo test- Event detection
- Trade decoding
- Transaction execution
- Error handling
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Submit a pull request
- TypeScript: Follow existing code style
- Rust: Run
cargo fmtbefore committing
This project is licensed under the MIT License - see the LICENSE file for details.
- Ethers.js team for the excellent library
- Ethers-rs team for the Rust implementation
- PancakeSwap team
- Four.meme team
- BNB Chain community
For issues, questions, or contributions:
- Open an issue on GitHub
- Check existing documentation
- Review troubleshooting section
This software is provided as-is for educational and research purposes. Trading cryptocurrencies involves substantial risk. Use at your own risk. The authors are not responsible for any losses incurred.
Made with β€οΈ for the BNB Chain community