I Sniped a Solana Token in 400ms — Here's the Full Tech Stack
Sniping tokens on Solana is a high-stakes game where milliseconds matter. Recently, I managed to snipe a trending token on Solana in just 400ms. In this post, I’ll break down the technical stack that made this possible, focusing on Jito MEV bundles, Jupiter routing, and Helius RPC. I’ll share real code snippets, lessons learned, and specific numbers to help you understand how it all works.
The Challenge: Speed and Precision
Sniping tokens on Solana involves executing a buy transaction as soon as a token launches. This requires:
- Extremely fast execution: Milliseconds can separate success from failure.
- MEV (Miner Extractable Value): Competing with bots and traders for priority.
- Optimal routing: Finding the best price and liquidity pool for the token.
Achieving this requires a carefully orchestrated tech stack. Here’s how I did it.
The Tech Stack
1. Jito MEV Bundles: Prioritizing Transactions
Jito Labs has revolutionized Solana MEV with their bundle system. Bundles allow you to group multiple transactions and ensure they’re executed together, giving you priority over individual transactions. This is critical for sniping.
Here’s how I used Jito bundles:
import { Connection, Transaction } from "@solana/web3.js";
import { JitoBundleSender } from "@jito-solana/bundle";
// Initialize connection and bundle sender
const connection = new Connection("https://api.mainnet-beta.solana.com");
const bundleSender = new JitoBundleSender(connection);
// Create a transaction to buy the token
const buyTx = new Transaction().add(
// Add instructions for buying the token
);
// Create a bundle with the buy transaction
const bundle = bundleSender.createBundle([buyTx]);
// Send the bundle
const bundleId = await bundleSender.sendBundle(bundle);
console.log(`Bundle sent with ID: ${bundleId}`);
Key takeaway: Bundles significantly increase the chances of your transaction being included in a block, especially during high network congestion.
2. Jupiter Routing: Finding the Best Price
Jupiter is Solana’s leading DEX aggregator, and it’s essential for finding the best route and price for a token. I integrated Jupiter’s API to ensure I was always getting the most efficient swap.
Here’s how I used Jupiter’s API:
import axios from "axios";
const jupiterApi = "https://quote-api.jup.ag/v6/quote";
async function getBestQuote(inputMint, outputMint, amount) {
const response = await axios.get(jupiterApi, {
params: {
inputMint,
outputMint,
amount,
slippageBps: 50, // 0.5% slippage
},
});
return response.data;
}
// Example usage
const inputMint = "So11111111111111111111111111111111111111112"; // SOL
const outputMint = "NEW_TOKEN_MINT_ADDRESS"; // Token to snipe
const amount = 1000000; // 1 SOL in lamports
const quote = await getBestQuote(inputMint, outputMint, amount);
console.log(`Best quote: ${quote.outAmount} tokens`);
Key takeaway: Jupiter’s API ensures you’re getting the best price and liquidity, even for newly launched tokens.
3. Helius RPC: Ultra-Fast Node Connections
Helius is a high-performance RPC provider for Solana, offering ultra-low latency and high reliability. For sniping, I used Helius’s turbine engine to ensure my transactions were propagated to the network as quickly as possible.
Here’s how I configured Helius:
import { Connection } from "@solana/web3.js";
// Initialize Helius RPC connection
const heliusRpcUrl = "https://helius-rpc.com"; // Replace with your Helius endpoint
const connection = new Connection(heliusRpcUrl);
// Example: Fetching the latest blockhash
async function fetchLatestBlockhash() {
const blockhash = await connection.getLatestBlockhash();
console.log(`Latest blockhash: ${blockhash.blockhash}`);
return blockhash;
}
fetchLatestBlockhash();
Key takeaway: Helius’s low-latency RPC ensures your transactions are processed faster than those sent through standard RPC nodes.
The Execution: How It All Came Together
Here’s the step-by-step flow of how I sniped the token:
Monitor New Tokens: I used a custom script to monitor Solana’s blockchain for newly created token addresses. This involved listening for
CreateAccountandInitializeMintinstructions.Calculate Swap Parameters: Once a new token was detected, I used Jupiter’s API to calculate the best route and amount for swapping SOL to the new token.
Build and Send Bundle: Using Jito’s bundle system, I grouped the swap transaction with a priority fee to ensure it was executed quickly.
Propagate via Helius: I sent the bundle through Helius’s RPC to minimize latency.
The entire process, from detecting the token to executing the swap, took 400 milliseconds.
Lessons Learned
1. Prioritize Fee Structure
High-priority fees are essential for ensuring your transactions are included in blocks. I always calculate fees dynamically based on network congestion.
2. Test Relentlessly
Sniping requires precision. I spent weeks testing my setup on Devnet and Testnet to ensure everything worked flawlessly on Mainnet.
3. Monitor Network Conditions
Solana’s network conditions can change rapidly. I built monitoring tools to track congestion and adjust my strategy in real-time.
Conclusion
Sniping tokens on Solana is a blend of speed, precision, and technical expertise. By leveraging Jito MEV bundles, Jupiter routing, and Helius RPC, I was able to secure a snipe in just 400ms. This stack isn’t just for sniping; it’s a powerful toolkit for anyone building high-frequency trading bots on Solana.
If you’re diving into Solana MEV or token sniping, start small, test extensively, and iterate. The ecosystem is evolving rapidly, and staying ahead requires constant learning and adaptation. Happy snipping!
🚀 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)