I Sniped a Solana Token in 400ms — Here's the Full Tech Stack
Sniping Solana tokens at launch has become a high-stakes game of speed and precision. Recently, I managed to snipe a highly sought-after token in just 400 milliseconds. In this article, I’ll break down the full tech stack I used, including Jito MEV bundles, Jupiter routing, and Helius RPC. I’ll also share code snippets, lessons learned, and exact numbers to help you replicate or improve upon this process.
The Challenge: Speed and Precision
Solana’s high throughput and low latency make it an ideal blockchain for token launches, but it also creates a fiercely competitive environment. To snipe a token successfully, you need to:
- Detect the token’s creation instantly.
- Route the transaction through the most efficient path.
- Submit the transaction faster than anyone else.
Let’s dive into how I achieved this.
Step 1: Detecting Token Creation with Helius RPC
Helius is a Solana RPC provider that offers ultra-low latency and high reliability. Their APIs were crucial for detecting token creation in real time. Specifically, I used the getProgramAccounts method to monitor the SPL Token program for new mints.
Here’s the Python code snippet I used:
from solana.rpc.api import Client
from solana.publickey import PublicKey
client = Client("https://mainnet.helius-rpc.com")
token_program_id = PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
def monitor_new_tokens():
filters = [
{"dataSize": 165}, # Size of a new token account
{"memcmp": {"offset": 0, "bytes": "new_mint"}}, # Filter for new mints
]
accounts = client.get_program_accounts(token_program_id, filters=filters)
for account in accounts:
print(f"New token detected: {account['pubkey']}")
This script uses Helius’s RPC endpoint to fetch new token accounts in real time. The dataSize filter ensures we only look at newly created accounts, and the memcmp filter helps identify relevant tokens.
Step 2: Routing Transactions with Jupiter
Once I detected a new token, I needed to route the transaction efficiently to minimize gas costs and latency. Jupiter is Solana’s leading decentralized exchange aggregator, and their API allowed me to find the best route for my transaction.
Here’s how I integrated Jupiter’s routing API:
import requests
def get_best_swap_route(input_mint, output_mint, amount):
url = "https://quote-api.jup.ag/v1/quote"
params = {
"inputMint": input_mint,
"outputMint": output_mint,
"amount": amount,
"slippage": "0.5" # 0.5% slippage tolerance
}
response = requests.get(url, params=params)
return response.json()
# Example usage
input_mint = "So11111111111111111111111111111111111111112" # SOL
output_mint = "NewToken1234567890123456789012345678901234567890" # New token
amount = 1000000 // 1 SOL
route = get_best_swap_route(input_mint, output_mint, amount)
print(f"Best swap route: {route}")
Jupiter’s API returns the optimal route for swapping tokens, including the necessary instructions and expected slippage. This was critical for ensuring my transaction was as cost-effective as possible.
Step 3: Submitting Transactions with Jito MEV Bundles
Jito is a Solana MEV (Maximal Extractable Value) infrastructure provider that allows you to bundle transactions for faster submission. By using Jito’s bundle system, I was able to front-run other bots and snipe the token in 400ms.
Here’s how I crafted and submitted a Jito bundle:
from solana.rpc.async_api import AsyncClient
from solana.transaction import Transaction
from solana.system_program import TransferParams, transfer
from jito_bundle import Bundle, BundleHeader, shuffle_bundle
async def submit_bundle(transactions):
client = AsyncClient("https://jito-mainnet.rpc.com")
bundle = Bundle(header=BundleHeader(transactions))
shuffled_bundle = shuffle_bundle(bundle) # Shuffle for MEV fairness
await client.send_bundle(shuffled_bundle)
# Example transaction
tx = Transaction().add(transfer(TransferParams(
from_pubkey=source_pubkey,
to_pubkey=destination_pubkey,
lamports=amount
)))
await submit_bundle([tx])
Jito’s bundle system ensures that your transaction is prioritized by the Solana network, giving you a significant speed advantage.
Lessons Learned
- Latency Matters: Helius’s RPC endpoint consistently delivered sub-100ms latency, which was crucial for detecting tokens early.
- Routing Optimization: Jupiter’s API saved me significant gas costs by finding the most efficient swap route.
- MEV Strategies: Jito’s MEV bundles allowed me to front-run competitors, but they come with ethical considerations. Always use MEV responsibly.
Exact Numbers
- Token Detection Time: ~50ms using Helius’s RPC.
- Routing Time: ~100ms using Jupiter’s API.
- Bundle Submission Time: ~250ms using Jito’s MEV bundles.
- Total Time: 400ms to snipe the token.
Conclusion
Sniping Solana tokens requires a combination of cutting-edge tools and meticulous execution. By leveraging Helius for token detection, Jupiter for efficient routing, and Jito for lightning-fast transaction submission, I was able to snipe a token in just 400ms. While these tools give you a competitive edge, it’s important to use them responsibly and ethically. Happy sniping!
🚀 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)