I Sniped a Solana Token in 400ms — Here's the Full Tech Stack
Sniping tokens on Solana is both an art and a science. With block times hovering around 400ms, the margin for error is razor-thin. Last week, I successfully sniped a freshly launched token on Solana, and today I’m breaking down the exact tech stack and techniques I used to make it happen. This is not just a theoretical guide; I’ll share real code snippets, practical examples, and the lessons I learned along the way.
The Problem: Speed and Precision
Sniping a token on Solana requires two things:
- Speed: You need to submit transactions the instant a new token is listed.
- Precision: Your transaction must be prioritized over others to ensure it’s included in the block.
Achieving both is no small feat. Solana’s high throughput and low block times make it incredibly competitive. To succeed, I relied on three key technologies: Jito MEV Bundles, Jupiter’s Swap API, and Helius RPC. Let’s dive into each.
Jito MEV Bundles: Prioritizing Transactions
Jito Labs introduced MEV bundles on Solana, enabling users to bundle transactions and pay for priority inclusion in a block. This was critical for sniping the token.
How It Works
Jito bundles allow you to submit a sequence of transactions that are executed atomically. You can attach a priority fee to ensure your bundle is prioritized by validators. For my snipe, I used a bundle to sequence two transactions:
- Swap SOL for the new token.
- Transfer the token to my wallet.
Here’s the code I used to create and submit a Jito bundle:
const { Connection, Keypair, Transaction } = require("@solana/web3.js");
const { Bundle, JitoClient } = require("@jito/solana");
// Initialize connection and client
const connection = new Connection("https://api.mainnet-beta.solana.com");
const jitoClient = new JitoClient(connection);
// Define transactions
const swapTx = createSwapTransaction(); // Assume this creates a swap tx
const transferTx = createTransferTransaction(); // Assume this creates a transfer tx
// Create bundle
const bundle = new Bundle([swapTx, transferTx], {
priorityFee: 0.01, // Pay 0.01 SOL for priority
});
// Submit bundle
const result = await jitoClient.sendBundle(bundle);
console.log("Bundle submitted with signature:", result.signature);
Lesson Learned: Adding a small priority fee (e.g., 0.01 SOL) significantly increases the chances of your bundle being included in the next block.
Jupiter’s Swap API: Optimizing the Swap
Jupiter is a decentralized exchange aggregator on Solana. Its Swap API allows you to find the best route for a token swap and generate a transaction. For my snipe, I used Jupiter to minimize slippage and ensure I got the best price.
How It Works
Jupiter’s API provides a quoteSwap endpoint that returns the optimal route for a swap. Here’s how I integrated it:
const axios = require("axios");
async function getSwapQuote(inputToken, outputToken, amount) {
const url = `https://quote-api.jup.ag/v1/quote?inputMint=${inputToken}&outputMint=${outputToken}&amount=${amount}`;
const response = await axios.get(url);
return response.data;
}
async function createSwapTransaction() {
const quote = await getSwapQuote("SOL", "NEW_TOKEN", 1); // Swap 1 SOL for NEW_TOKEN
const { swapTransaction } = await axios.post("https://swap-api.jup.ag/v1/swap", {
quoteResponse: quote,
userPublicKey: "YOUR_PUBLIC_KEY",
});
return Object.assign(new Transaction(), swapTransaction);
}
Lesson Learned: Always fetch a fresh quote right before submitting the transaction. Token prices can fluctuate wildly in seconds.
Helius RPC: Lightning-Fast API Calls
Helius is an RPC provider optimized for Solana. Its low-latency endpoints were crucial for monitoring the blockchain and detecting the token launch.
How It Works
Helius offers enhanced APIs for token metadata and real-time monitoring. I used the getTokenMetadata endpoint to detect the new token and its mint address:
const { default: axios } = require("axios");
async function detectNewToken() {
const url = "https://api.helius.xyz/v1/token-metadata";
const response = await axios.post(url, {
mintAddresses: ["NEW_TOKEN_MINT"],
includeOffChain: true,
});
return response.data[0];
}
For real-time monitoring, I subscribed to Helius’s WebSocket feed:
const WebSocket = require("ws");
const ws = new WebSocket("wss://api.helius.xyz/v1/websocket");
ws.on("message", (data) => {
const event = JSON.parse(data);
if (event.type === "TOKEN_MINT") {
console.log("New token minted:", event.mintAddress);
// Trigger snipe logic
}
});
Lesson Learned: Use WebSocket feeds for real-time monitoring instead of polling. It’s faster and reduces API rate limits.
Putting It All Together
Here’s the step-by-step workflow I used:
- Monitor Token Launches: Use Helius’s WebSocket feed to detect new token mints.
- Fetch Swap Quote: Use Jupiter’s API to get the optimal swap route.
- Create Bundle: Use Jito to bundle the swap and transfer transactions.
- Submit Bundle: Send the bundle with a priority fee.
The entire process, from detecting the token to submitting the bundle, took under 400ms.
Lessons Learned
- Priority Fees Are Worth It: Adding a small priority fee ensures your transaction is processed quickly.
- Real-Time Monitoring Is Key: WebSocket feeds are indispensable for reacting instantly to on-chain events.
- Optimize Your Code: Every millisecond counts. Profile your code to eliminate bottlenecks.
Conclusion
Sniping tokens on Solana is a thrilling challenge that combines speed, precision, and technical prowess. By leveraging Jito MEV bundles, Jupiter’s Swap API, and Helius RPC, I was able to execute a successful snipe in just 400ms. If you’re diving into this space, focus on optimizing every step of your workflow—because in Solana’s fast-paced environment, even a single millisecond can make the difference.
🚀 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)