Building a Solana sniper bot: data feed, detector, sender and exit
A Solana sniper bot is five stages: a data feed, a decoder, a launch detector with risk filters, a transaction builder and a sender. Most of its speed is decided by the feed, because shreds expose a new token's create transaction while that slot is still under construction. The rest of the work is rejecting bad launches and confirming what actually landed.
Shredstream.sh Editorial Team · 10 min read · updated

Search for a Solana sniper bot and you get two kinds of results: Telegram bots that want your private key, and GitHub repositories that poll an RPC endpoint in a loop. Both work, in the sense that they eventually buy tokens. Neither tells you why one bot fills at the first price on the curve and another fills ten buyers later at a worse one.
This guide is the version we would want if we were starting from zero: what each stage of the bot does, which choices actually move your fill price, and the step almost every free bot leaves out.
What a sniper bot actually does
Strip away the dashboards and a sniper bot is a pipeline with one job: notice that a token or pool now exists, decide whether to buy it, and get a buy transaction into a block as close as possible to the creation.
Every stage costs time, but not equally. The decoder, detector and builder run in your own process and cost microseconds when written sensibly. The feed and the sender cross the network and cost milliseconds, sometimes hundreds of them. So the order of work for anyone building one is clear: fix the feed first, the sender second, and only then worry about code speed.
Stage 1: pick the data feed, because it sets your ceiling
Your bot cannot react to a launch earlier than the moment it learns about it. That moment depends entirely on where in Solana's pipeline your data comes from.
The reason shreds come first is structural rather than a vendor claim. A leader cuts the block it is building into shreds and pushes them out through Turbine as it goes. A Geyser plugin only sees a transaction once its validator has received those shreds, reassembled them and replayed them. RPC sees it later still. Every other feed is downstream of shreds.
The trade is effort. RPC hands you parsed JSON. Shreds hand you UDP datagrams that may arrive out of order, may be missing, and must be reassembled before you can read a single instruction. If you are new to this, start on a decoded feed, get the strategy right, and move to raw shreds once you know the early sight is worth the decoding work.
A practical rule: if your bot competes against other bots on the same launches, a polling or WebSocket feed means you are reading about the launch after the fastest buyers have already sent their transactions.
Stage 2: turn packets into transactions
A shred feed gives you pieces of entries, and each entry holds a batch of transactions. Your decoder has to bucket incoming shreds per slot and per erasure set, use coding shreds to rebuild any lost data shreds once enough of them have arrived, deserialize entries, and pull out each VersionedTransaction. The mechanics are walked through in from entry to transaction and in the transaction extraction docs.
Two design choices matter for a sniper specifically:
- Decode as soon as an entry is complete, not when the slot is complete. Waiting for the whole slot throws away most of the lead the feed gave you.
- Keep the decoder on its own core. Packet receive and decode are bursty, and you do not want a detector or signing step stalling the socket buffer.
Stage 3: detect the launch, then try hard to reject it
Detection is cheap. For an Anchor program such as Pump.fun, the test is a program id match plus an 8-byte prefix check on the data buffer. For older programs you compare a tag byte and check the account count. The launch detection guide covers the byte patterns in detail.
rust
// Hot path: called for every decoded transaction.const PUMP_PROGRAM: Pubkey = pubkey!("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");const PUMP_CREATE: [u8; 8] = [0x18, 0x1e, 0xc8, 0x28, 0x05, 0x1c, 0x07, 0x77]; fn find_launch(tx: &VersionedTransaction) -> Option<Launch> { let keys = tx.message.static_account_keys(); for ix in tx.message.instructions() { let program = keys.get(ix.program_id_index as usize)?; if *program == PUMP_PROGRAM && ix.data.starts_with(&PUMP_CREATE) { let mint = *keys.get(*ix.accounts.first()? as usize)?; let curve = *keys.get(*ix.accounts.get(2)? as usize)?; return Some(Launch { mint, curve, slot_seen: now() }); } } None}The hard part is the filter that runs next. Most launches are not worth buying, and a bot that buys everything is a donation machine. Useful checks, roughly in order of cost:
- Mint and freeze authority. If the creator can still mint more supply or freeze your token account, skip it. On Pump.fun these are handled by the program, but on hand-rolled Raydium or Meteora launches you must check.
- Token-2022 extensions. A transfer hook, a permanent delegate or a transfer fee can make a token impossible or expensive to sell.
- The dev buy. A large purchase by the creator inside the launch transaction often means they plan to sell into you.
- Creator history. Keep a local table of wallets that launched tokens and dumped them. This is the filter that pays for itself fastest.
- Metadata. Name, symbol and URI are in the create instruction. Blocklists for copied names catch a lot of impersonation launches.
Everything in that list must come from data you already hold in memory. A filter that calls an RPC endpoint puts a network round trip back into the hot path and erases the lead you paid for in Stage 1.
Stage 4: build the buy before you need it
The fastest builders do almost nothing at the moment of detection. Before any launch arrives, they keep ready:
- a recent blockhash, refreshed every few seconds from an ordinary RPC node;
- the compute budget instructions (unit limit and unit price) for the current fee level;
- the instruction template for the target program, with only the mint, curve and amounts left to fill;
- an idempotent create instruction for your associated token account, so the buy does not fail because the account does not exist yet.
At detection time the builder fills in the accounts, sets a hard maximum on what it will pay, and signs. Set that slippage bound deliberately. Without it, the bot will happily buy at whatever price the earlier buyers have pushed the curve to.
Stage 5: send it where it will land
A signed transaction is not a filled order. There is no public mempool on Solana, so the transaction has to reach the current leader directly, and leaders prioritise. Three levers decide whether yours gets in:
- Priority fee. Set through the compute unit price. Higher fees win ordering within the leader's scheduler.
- Bundle or tip relays. Block engine style relays let you attach a tip and ask for atomic inclusion, which also protects you from being sandwiched.
- Stake-weighted paths. Leaders reserve most inbound connection capacity for staked senders. Sending through a staked connection (SWQoS) gets your packet through when the leader is congested.
Serious bots send the same signed transaction down more than one path at once. The signature is the same, so it can only land once, and whichever path is fastest that slot wins.
The step most free bots skip: reconciliation
Seeing a create transaction in shreds proves the leader proposed it. Whether it executed, whether the slot survived, and whether your own buy got in are separate questions. Forks happen, leaders miss slots, and transactions revert.
So the bot needs a second, slower loop: watch confirmed-commitment data for every buy it sent, and update positions only from that. When the two disagree, the confirmed view wins. The page on forks and skipped slots, linked at the end of this guide, explains how often this happens and how to handle each case. A bot without this loop eventually reports positions it does not hold.
Exits matter more than entries
Getting in first is the visible part. Getting out is where the money is made or lost. Decide before launch day:
- a take-profit ladder rather than one target;
- a time stop, because most new tokens lose attention within minutes;
- a hard rule for the creator selling, which you can detect with the same shred feed you used for the entry;
- what happens at migration, when a Pump.fun token leaves the bonding curve for an AMM pool and your sell route changes.
Free sniper bots, GitHub code and what they cost you
The "free" options are real, but read the costs carefully.
- Telegram sniper bots usually hold your private key on their servers and take a fee per trade. You are trusting their custody and their infrastructure, which you cannot inspect.
- Open-source bots on GitHub are excellent for learning the instruction layouts. Most poll a public RPC endpoint, which puts them in the slowest row of the table above. Read every line before running one, and never paste a funded private key into code you have not read: malicious forks of popular sniper repositories that exfiltrate keys are common.
- Free RPC tiers rate-limit exactly when a hot launch makes everyone poll at once.
Free gets you a working bot. It does not get you an early one.
Where shredstream.sh fits
We sell the Stage 1 input: Solana shreds delivered over raw UDP from Frankfurt, to an IP and port you choose. You bring the decoder, detector and sender. If you want to see the difference before you pay, try two free hours of Premium Shreds on your own server, and the first-shred race compares arrival times against whatever feed you use today.
In practice
A launch transaction leaves the leader inside slot N. A bot on a shred feed receives the shreds carrying that entry while slot N is still in progress, decodes the transaction, and its detector matches the Pump.fun create discriminator.
The filters run from memory: the creator wallet is not on the dump list, the dev buy is small, and the name is not on the impersonation blocklist. The builder fills the mint and curve into a pre-built buy template with a maximum SOL cost set two percent above the computed price, signs it with a blockhash fetched three seconds earlier, and sends it through a staked path and a tip relay together.
Twenty seconds later the reconciliation loop sees the buy at confirmed commitment and records the position. Had slot N been skipped, the loop would have found no buy, and the bot would have recorded nothing rather than a phantom position.
Scope of this page
This guide describes the architecture of a sniper bot and the data path that feeds it. It does not cover trading strategy, position sizing, tax or the legal status of automated trading where you live, and it is not financial advice. Most newly launched tokens lose value quickly.
Program ids, discriminators and account positions belong to deployed programs that change when they are upgraded. Treat the constants in the code as examples to verify against the current IDL. The ordering of feeds in the timeline is structural; the size of the gaps between them depends on your region, provider and receiver, and you should measure it rather than assume it.
Related questions
The earliest feed is shreds, because they carry a new token's create transaction during block production, before the slot closes. Geyser gRPC sees the same transaction only after a validator replays it, and RPC polling or WebSocket subscriptions see it later still. The trade off is effort: shreds arrive as raw UDP packets that the bot must reassemble and decode itself.
Some are, many are not. Open-source sniper repositories are useful for learning instruction layouts, but malicious forks that send your private key to an attacker are common. Read every line before running one, run it with a fresh wallet holding only what you can lose, and expect most free bots to be slow because they poll a public RPC endpoint.
Fast enough to beat the other bots on the same launch, which means the feed matters more than code speed. A Solana slot lasts about 400 milliseconds, and competitive bots act within the same slot as the create transaction. Decoding and signing take microseconds; the network legs to receive the launch and to reach the leader take milliseconds, so those are where to spend effort.
Being sent first does not guarantee being included first. The leader orders transactions by priority fee and admits staked connections ahead of unstaked ones, so a later transaction with a higher fee or a better path can land ahead of yours. Buys also fail when the price moves past your slippage limit or when the associated token account is missing.
It can avoid many of them, not all. Filters that check mint and freeze authority, risky Token-2022 extensions, the size of the dev buy, and a local history of wallets that dumped earlier launches remove a large share of bad tokens. None of them can predict a creator who behaves honestly once and then sells into buyers the next time.
Read next
Ready to build against this? The documentation covers the implementation.