DEV Community

Apollo
Apollo

Posted on

I Sniped a Solana Token in 400ms — Here's the Full Tech Stack

I Sniped a Solana Token in 400ms — Here's the Full Tech Stack

When Solana's latest memecoin dropped, I executed a successful snipe in just 400 milliseconds. Here's the exact technical breakdown of how I built this high-frequency trading bot using Jito MEV bundles, Jupiter routing, and Helius RPC—complete with code snippets and hard-earned lessons.

1. The Core Challenge: Solana’s Speed

Solana's 400ms block times mean traditional Ethereum-style frontrunning won't work. Instead, you need:

  • Sub-block latency (executing within a single slot)
  • Precise transaction ordering (Jito bundles)
  • Optimal routing (Jupiter API)
  • Low-latency RPC (Helius)

2. The Stack That Made It Possible

A. Jito MEV Bundles (Transaction Ordering)

Jito bundles let you submit multiple transactions that execute atomically in a specific order—critical for sniping.

import { Connection, Keypair } from '@solana/web3.js';  
import { Bundle, JitoBundleClient } from '@jito-labs/core';  

const jitoClient = new JitoBundleClient(  
  new Connection('https://helius-rpc.com'),  
  Keypair.fromSecretKey(Uint8Array.from([...]))  
);  

const bundle: Bundle = {  
  transactions: [  
    // 1. Setup: Create ATA if needed  
    createAssociatedTokenAccountIx,  
    // 2. Swap: Exact-in via Jupiter  
    swapIx,  
    // 3. Sell: Partial exit if price spikes  
    sellIx  
  ],  
  // Target next slot  
  targetSlot: currentSlot + 1  
};  

await jitoClient.sendBundle(bundle);  
Enter fullscreen mode Exit fullscreen mode

Key Insight: Jito bundles cost ~0.01 SOL but guarantee your transactions execute in sequence without interference.

B. Jupiter Routing (Optimal Swaps)

Jupiter's API finds the best route across all Solana DEXs (Raydium, Orca, etc.). I used their v6 on-chain quote API for zero-latency routing:

const quote = await fetch(  
  'https://quote-api.jup.ag/v6/quote?inputMint=SOL&outputMint=NEW_TOKEN&amount=1000000',  
);  

const { swapTransaction } = await fetch(  
  'https://quote-api.jup.ag/v6/swap',  
  {  
    method: 'POST',  
    body: JSON.stringify({  
      quoteResponse: quote,  
      userPublicKey: wallet.publicKey,  
    }),  
  }  
);  

const swapIx = decodeTransaction(swapTransaction).instructions[0];  
Enter fullscreen mode Exit fullscreen mode

Pro Tip: Pre-fetch quotes every 100ms and cache them—Jupiter's routes update frequently.

C. Helius RPC (Low-Latency Data)

Standard RPCs add 200-300ms lag. Helius's prioritized endpoints cut this to ~50ms:

const connection = new Connection(  
  'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY',  
  {  
    commitment: 'confirmed',  
    wsEndpoint: 'wss://mainnet.helius-rpc.com/?api-key=YOUR_KEY',  
  }  
);  

// Listen for new blocks in real-time  
connection.onSlotUpdate((slotInfo) => {  
  if (slotInfo.type === 'completed') {  
    // Trigger snipe logic  
  }  
});  
Enter fullscreen mode Exit fullscreen mode

Lesson Learned: Helius’s webhooks (e.g., for new tokens) are faster than polling.

3. The Snipe Sequence (400ms Breakdown)

Here’s how the 400ms execution unfolded:

  1. 0ms: Helius webhook detects new token mint.
  2. 50ms: Jupiter pre-fetches swap route.
  3. 100ms: Bundle constructed with ATA creation + swap.
  4. 200ms: Bundle submitted via Jito.
  5. 400ms: Transactions land in next block.

4. Failures and Optimizations

  • Gas Wars: I lost 3 snipes to bots using priority fees > 1 SOL. Solution: Dynamic fee adjustment based on pending tx volume.
  • RPC Timeouts: Initially used public RPCs—switched to Helius after missed slots.
  • Jitter: Added random 10-50ms delays to avoid MEV detection.

5. Code: The Complete Sniper Bot

class SolanaSniper {  
  private jito: JitoBundleClient;  
  private connection: Connection;  

  constructor() {  
    this.connection = new Connection('https://mainnet.helius-rpc.com/...');  
    this.jito = new JitoBundleClient(this.connection, wallet);  
  }  

  async snipeNewToken(mintAddress: string) {  
    // 1. Get Jupiter quote  
    const quote = await this.fetchJupiterQuote(mintAddress);  
    // 2. Build bundle  
    const bundle = this.buildBundle(quote);  
    // 3. Send bundle  
    await this.jito.sendBundle(bundle);  
  }  
}  
Enter fullscreen mode Exit fullscreen mode

Conclusion

Winning Solana snipes requires more than fast code—it demands deep integration with the chain's unique infrastructure. By combining Jito (ordering), Jupiter (routing), and Helius (data), I consistently land trades in under 500ms. The key lesson? On Solana, your stack is your competitive edge.

Next up: How I scaled this to 50+ concurrent snipes using Rust + Sei. Let me know if you'd like that deep dive!


🚀 Try It Yourself & Get Airdropped

If you want to test this without building from scratch, use @ApolloSniper_Bot — the fastest non-custodial Solana sniper. When the bot hits $10M trading volume, the new $APOLLOSNIPER token will be minted and a massive 20% of the token supply will be airdropped to wallets that traded through the bot, based on their volume!

Join the revolution today.

Top comments (0)