A sophisticated cryptocurrency trading bot designed for automated token sniping and MEV (Maximal Extractable Value) strategies on the BNB Smart Chain (BSC).
This bot implements MEV strategies including front-running tactics. Use at your own risk. The authors are not responsible for any financial losses. Always test thoroughly on testnets before using on mainnet.
- Automated Token Sniping: Execute buy orders instantly when new tokens are detected
- MEV Strategy: Front-running and back-running capabilities
- Take Profit Automation: Automated selling with configurable slippage protection
- Gas Optimization: Dynamic gas pricing for transaction priority
- Admin Panel: Complete management interface for configuration
- Real-time Monitoring: Block height, price, and transaction monitoring
- Retry Logic: 3-attempt retry system for failed transactions
- Pair Filtering: Advanced liquidity-based token pair filtering
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Express API β β MongoDB β
β (Admin Panel) βββββΊβ Server βββββΊβ Database β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β BSC Network β
β (Web3.js) β
βββββββββββββββββββ
- Node.js (v14 or higher)
- MongoDB database
- BSC RPC endpoint
- Private keys for trading wallets
-
Clone the repository
git clone <repository-url> cd bnbSniperBot
-
Install dependencies
npm install
-
Environment Setup Create a
.envfile in the root directory:# Database MONGODB_URI=mongodb://your-mongodb-connection-string # BSC Network POLYGON_RPC_URL=https://bsc-dataseed.binance.org/ QUICKNODE_WS_URL=wss://your-quicknode-ws-url # Trading Configuration PRIVATE_KEY=your-private-key WALLET_ADDRESS=your-wallet-address ROUTER_ADDRESS=0x10ED43C718714eb63d5aA57B78B54704E256024E WETH_ADDRESS=0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c USDT_ADDRESS=0x55d398326f99059fF775485246999027B3197955 # Trading Parameters MIN_TRADE_AMOUNT=0.1 MIN_TARGET_AMOUNT=100 SLIPPAGE_BPS=100 # JWT Secrets JWT_SECRET=your-jwt-secret-key # External APIs POL_PRICE_API=https://api.coingecko.com/api/v3/simple/price?ids=polygon&vs_currencies=usd SUBGRAPH_URL=https://gateway.thegraph.com/api/your-api-key/subgraphs/id/your-subgraph-id
-
Start the application
npm start
The server will start on http://localhost:3000
POST /api/signup
Content-Type: application/json
{
"username": "your-username",
"password": "your-password"
}POST /api/login
Content-Type: application/json
{
"username": "your-username",
"password": "your-password"
}POST /admin/signup
Content-Type: application/json
{
"username": "admin-username",
"password": "admin-password"
}POST /api/runBot
Authorization: Bearer <your-jwt-token>
Content-Type: application/json
{
"privatekey": "0x...",
"gasGiven": "5"
}GET /api/getData?type=blockheight
GET /api/getData?type=pendingTx
GET /api/getData?type=polPricePOST /admin/storePrivateKeys
Authorization: Bearer <admin-jwt-token>
Content-Type: application/json
{
"privateKeys": ["0x...", "0x...", "0x..."]
}POST /admin/updateConfig
Authorization: Bearer <admin-jwt-token>
Content-Type: application/json
{
"tokenAddress": ["0x...", "0x..."],
"purchaseAmount": 250
}POST /admin/runSimulation
Authorization: Bearer <admin-jwt-token>
Content-Type: application/json
{
"privatekey": "0x..."
}POST /admin/filteredPairs
Content-Type: application/json
{
"first": 100,
"skip": 0,
"minLiquidity": 10000,
"maxLiquidity": 100000
}| Variable | Description | Required |
|---|---|---|
MONGODB_URI |
MongoDB connection string | Yes |
POLYGON_RPC_URL |
BSC RPC endpoint | Yes |
PRIVATE_KEY |
Default private key for trading | Yes |
ROUTER_ADDRESS |
DEX router contract address | Yes |
WETH_ADDRESS |
WBNB token address | Yes |
MIN_TRADE_AMOUNT |
Minimum trade amount in BNB | No |
SLIPPAGE_BPS |
Slippage tolerance in basis points | No |
The bot uses an admin configuration system to manage:
- Target token addresses
- Purchase amounts
- Current trading index
- Private key rotation
-
Automated Sell Bot (
automatedSellBot.js)- Runs every 30 seconds
- Processes pending transactions
- Executes automated selling
-
Market Data Collector (
marketDataCollector.js)- Runs every 20 seconds
- Collects block height data
- Monitors POL price
- Tracks pending transactions
The bot implements a robust retry system:
- 3 attempts for failed transactions
- Dynamic gas price adjustment
- Slippage protection
- Error logging and monitoring
- User: User authentication and management
- Admin: Admin user management
- adminConfig: Trading configuration
- targetedAccount: Private key management
- targetedTransaction: Transaction tracking
- BlockHeight: Block height monitoring
- PolPrice: Price data collection
- PendingTx: Pending transaction monitoring
- JWT-based authentication
- Password hashing with bcrypt
- Private key encryption
- Input validation and sanitization
- Rate limiting (recommended to implement)
- Slippage Protection: Configurable slippage tolerance
- Gas Limits: Prevents excessive gas consumption
- Balance Checks: Validates wallet balances before trading
- Error Handling: Comprehensive error catching and logging
- Transaction Timeouts: Prevents hanging transactions
The bot provides real-time monitoring of:
- Block height changes
- Token prices
- Pending transaction counts
- Trading performance
- Error rates
bnbSniperBot/
βββ config/ # Configuration files
βββ controllers/ # Business logic
βββ models/ # Database schemas
βββ routes/ # API routes
βββ utils/ # Utility functions
βββ automatedSellBot.js # Automated selling
βββ marketDataCollector.js # Data collection
βββ tokenPairFilter.js # Pair filtering
βββ server.js # Main application
- Create new routes in
routes/ - Add business logic in
controllers/ - Update database models if needed
- Test thoroughly on testnet
-
Transaction Failures
- Check gas prices
- Verify wallet balances
- Ensure token approvals
-
Database Connection Issues
- Verify MongoDB URI
- Check network connectivity
- Validate credentials
-
Web3 Connection Problems
- Verify RPC endpoint
- Check network status
- Validate contract addresses
Enable debug logging by setting:
DEBUG=true
NODE_ENV=developmentThis project is for educational purposes only. Use at your own risk.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For support and questions:
- Create an issue in the repository
- Check the troubleshooting section
- Review the API documentation