Skip to content

JavaScript-based token sniping bot for Base blockchain. Features WebSocket monitoring, deployer filtering, and optimized gas settings for sub-second trading execution.

Notifications You must be signed in to change notification settings

Adeshh/sniperBotJs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Ultra-Fast Token Sniping Bot

A high-performance cryptocurrency sniping bot designed for detecting and trading newly deployed tokens on Base blockchain with sub-second execution times.

⚑ Features

  • Ultra-Fast Detection: WebSocket-based token detection with deployer filtering
  • Zero Fake Tokens: Only monitors trusted deployer addresses
  • Immediate Swap Execution: Sub-second transaction submission
  • Optimized Gas Configuration: Base chain optimized gas settings
  • Real-time Monitoring: Live event detection with timestamps

πŸ“ Project Structure

β”œβ”€β”€ index.js                     # Main execution file
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ ultra_fast_detector.js   # Token detection engine
β”‚   └── swap.js                  # Swap execution logic
β”œβ”€β”€ abi/
β”‚   └── uniswapRouterABI.json    # Uniswap router contract ABI
β”œβ”€β”€ scrap/                       # Archive/backup files
β”œβ”€β”€ .env                         # Environment configuration
β”œβ”€β”€ package.json                 # Dependencies
└── README.md                    # This file

πŸ› οΈ Setup

1. Install Dependencies

npm install ethers dotenv

2. Environment Configuration

Create a .env file in the root directory:

# ============================================================================
# BLOCKCHAIN CONNECTION
# ============================================================================

# Base Chain WebSocket URL (Required)
# Get from: Alchemy, Infura, or other RPC provider
WSS_URL=wss://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY_HERE

# Alternative WebSocket URLs:
# WSS_URL=wss://base-mainnet.infura.io/ws/v3/YOUR_PROJECT_ID
# WSS_URL=wss://base.llamarpc.com

# ============================================================================
# WALLET CONFIGURATION
# ============================================================================

# Your wallet private key (KEEP THIS SECURE!)
# ⚠️ NEVER share this or commit it to version control
# Format: 64-character hex string (with or without 0x prefix)
PRIVATE_KEY=your_64_character_private_key_here_without_0x_prefix

# ============================================================================
# SMART CONTRACT ADDRESSES
# ============================================================================

# Uniswap V2 Router on Base Chain
UNISWAP_ROUTER_ADDRESS=0x4752ba5dbc23f44d87826276bf6fd6b1c372ad24

# ============================================================================
# OPTIONAL SETTINGS
# ============================================================================

# Node.js environment (optional)
NODE_ENV=production

# Logging level (optional)  
LOG_LEVEL=info

Setup Steps:

  1. Copy the above content to a new .env file
  2. Replace YOUR_API_KEY_HERE with your actual Alchemy/Infura API key
  3. Replace your_64_character_private_key_here_without_0x_prefix with your wallet's private key
  4. Keep the .env file secure and never commit it to version control

3. Pre-approve VIRTUALS Token

Before running the bot, approve unlimited VIRTUALS spending:

// This needs to be done once manually
await virtualsContract.approve(routerAddress, ethers.MaxUint256);

🎯 Configuration

Trading Parameters (index.js)

const APPROVAL_AMOUNT = ethers.parseEther("100000000"); // 100M tokens
const AMOUNT_IN = ethers.parseEther("200");             // 200 VIRTUALS
const VIRTUALS_ADDRESS = "";

Gas Settings (utils/swap.js)

const ULTRA_FAST_GAS = {
  gasLimit: 250000,
  maxFeePerGas: ethers.parseUnits('40', 'gwei'),     // Adjust for Base chain
  maxPriorityFeePerGas: ethers.parseUnits('20', 'gwei')
};

πŸš€ Usage

Start the Bot

node index.js

Expected Output

πŸ” Starting...
⚑ Monitoring deployer: 
πŸš€ 0x1234abcd... | 2025-05-29T15:30:45.123Z
πŸš€ Swap submitted: 0xabcd1234... | 2025-05-29T15:30:45.234Z
βœ… Approval submitted: 0xef567890...
🎯 Complete: 0x1234abcd...

⚑ Performance Optimizations

1. Deployer Filtering

  • Only monitors events from trusted deployer
  • Eliminates 90-99% of false positives
  • 5-10x faster detection

2. No Transaction Waiting

  • Submits transactions immediately
  • Doesn't wait for confirmation
  • Sub-second execution times

3. Optimized Event Processing

  • Direct callback execution
  • Zero unnecessary logging in critical path
  • Minimal memory allocation

4. WebSocket Efficiency

  • Single event listener
  • No polling or API calls
  • Real-time event detection

⚠️ Important Notes

Security

  • Never commit your .env file
  • Keep private keys secure
  • Test with small amounts first

Gas Optimization

  • Base chain uses very low gas (0.001-0.01 gwei)
  • Current settings are aggressive for speed
  • Adjust based on network conditions

Pre-requirements

  • VIRTUALS tokens in wallet
  • ETH for gas fees
  • Unlimited VIRTUALS approval to router

Risk Management

  • Test thoroughly before live trading
  • Monitor gas prices
  • Start with small amounts
  • Have exit strategy ready

πŸ”§ Troubleshooting

Common Issues

  1. "Insufficient allowance" error

    • Solution: Pre-approve VIRTUALS token spending
  2. "Gas price too high" error

    • Solution: Reduce gas settings in ULTRA_FAST_GAS
  3. No token detection

    • Check WebSocket connection
    • Verify deployer address
    • Confirm event topic
  4. Slow execution

    • Check network latency
    • Optimize gas settings
    • Verify no unnecessary logging

πŸ“Š Monitoring

Real-time Metrics

  • Detection timestamp
  • Transaction submission time
  • Token address detection
  • Block number tracking

Performance Tracking

  • Monitor execution times
  • Track successful swaps
  • Analyze gas usage

🚨 Disclaimer

This bot is for educational purposes. Cryptocurrency trading involves significant risk. Always:

  • Test thoroughly
  • Start with small amounts
  • Understand the risks
  • Trade responsibly

Built for maximum speed and precision on Base blockchain ⚑

About

JavaScript-based token sniping bot for Base blockchain. Features WebSocket monitoring, deployer filtering, and optimized gas settings for sub-second trading execution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published