Book a free call

How to Build a Crypto Sniper Bot, Step by Step

A crypto sniper bot buys a token the moment it becomes tradable, before human traders can react. Here is how it works and how to build one safely.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How to Build a Crypto Sniper Bot, Step by Step
On this page

Short answer

A crypto sniper bot is an automated program that buys a token the moment it becomes tradable on a decentralised exchange, usually within the same block that liquidity is added. It watches the chain for the launch signal, checks the token can be sold, and sends a pre-built buy before human traders react.

What is a crypto sniper bot?

A crypto sniper bot is an automated trading program that buys a token the moment it becomes tradable on a decentralised exchange, usually within the same block that liquidity is added. It watches the chain for the launch signal, then sends a pre-built buy transaction before human traders can react.

The edge is speed, not prediction. On a new pool, the first buyer gets the lowest price by definition, and enough human buyers arrive in the minutes after launch to sell into. The bot does not judge whether a token is good; it aims to be the first buyer on every launch it watches, with a position sized so that the losers are covered by the winners.

Sniper bots run on chains where token launches are frequent, mainly Ethereum, BNB Chain and Solana. Some are sold as ready-made tools with a chat interface, and others are custom programs a team builds for itself. For the wider trading-bot picture, see how to create an Ethereum trading bot.

How does a sniper bot work?

Every sniper bot follows the same four stages: watch, decide, fire and exit. The differences between bots are in how fast each stage runs and how many checks it makes before spending money.

StageWhat the bot doesWhat decides success
WatchListens for pool creation and liquidity eventsNode speed and latency
DecideSimulates a buy and a sell against chain stateHoneypot and tax checks
FireSends a pre-signed buy with set gas and slippagePriority fee and ordering
ExitSells at a take-profit, stop-loss or time limitPre-set rules, not emotion

Detection works in three ways. The bot watches for pool-creation events from a DEX factory, watches pending transactions in the mempool for the liquidity transaction, or watches a launchpad's own contracts. On chains with a public mempool, the pending liquidity transaction is visible before it executes, so the bot can prepare its buy to land immediately after it.

Before buying, a serious bot simulates the trade against a local copy of the chain: does the sell succeed, what share of the tokens arrives after any transfer tax, and can the owner pause transfers or change fees. A buy that cannot be sold is a honeypot, and the simulation is what catches it.

What do you need before you build?

A sniper bot needs four things before it can trade: a fast chain connection, a funded wallet, a list of targets and a set of rules. Skipping any of them is the usual reason a first bot loses money.

  • A fast node connection. The bot reads the chain through a node, and a shared public endpoint is too slow at launch. Most builders use a paid RPC provider or run their own node close to the chain's validators.
  • A funded wallet. The wallet holds the trading funds and pays gas. Keep its balance separate from any long-term holdings, and never give the bot access to more than it is allowed to lose.
  • A target list. Decide in advance which chains, launchpads and token types the bot will trade, and which it will ignore.
  • Written rules. Position size, maximum slippage, take-profit and stop-loss levels, and a daily loss limit, all set before the first trade.

The build itself is usually a program in Python, TypeScript or Rust that talks to the chain through a library such as ethers.js or web3.py on EVM chains, or through the Solana web3 library on Solana. For how token launches are structured, see how to create a token on Solana.

How to build a sniper bot, step by step

Building a sniper bot is a sequence of small, testable pieces. Build and test each one on a testnet before any real funds are involved.

  1. Connect to the chain. Set up the node connection and subscribe to new blocks and pending transactions, so the bot sees events as they happen.
  2. Detect launches. Listen for pool-creation events from the DEX factory and for liquidity transactions in the mempool, and extract the token address from each one.
  3. Add safety checks. Before any buy, simulate a sell against local chain state, read the token's transfer tax and ownership rules, and reject tokens that cannot be sold or that cap the wallet size.
  4. Build the buy. Pre-sign a swap transaction with the amount, slippage and gas settings filled in, so the token address is the only thing added at the last moment.
  5. Set the exit rules. Add take-profit, stop-loss and time-based exits, and make the bot sell automatically when any of them is hit.
  6. Test on a testnet. Run the bot against test launches with no real money, and measure how often it buys, how often it sells, and how much gas it spends.
  7. Start small. Go live with a tiny position size and a daily loss limit, and only raise the size after a week of trades you can explain.

Most of the work is in step three. A bot that buys fast but never checks the token will buy honeypots, and a bot that checks slowly will miss every launch. The balance between speed and safety is the whole design problem.

How do sniper bots deal with MEV and front-running?

A buy sitting in the public mempool can be seen by other bots, which may buy just before it and sell just after, pushing the price up in between. This is called a sandwich, and it is the main reason a sniper's buy can arrive at a much worse price than expected.

The usual answer is private routing. On Ethereum, services such as Flashbots let a transaction be sent straight to block builders without appearing in the public mempool, so nobody can jump ahead of it. The trade-off is that private transactions can be slower to include, and they do not work on every chain.

The other answer is the priority fee. A bot that pays a higher fee is ordered ahead of normal traffic in the same block, which matters on chains where ordering follows the fee. On chains with first-come-first-served ordering, raw latency matters instead: the bot connected directly to the sequencer with the lowest round trip wins. For the related risk of borrowed funds, see what flash loans in DeFi are.

Example (hypothetical): a first snipe

Example (hypothetical): a trader builds a sniper bot for a new token launch and sets a position of 1 ETH. The token launches at 0.0001 ETH per token, so the bot's buy gets 1 / 0.0001 = 10,000 tokens.

Interest arrives quickly and the price rises to 0.0003 ETH per token. The bot's take-profit rule triggers and it sells all 10,000 tokens, receiving 10,000 x 0.0003 = 3 ETH. The gas for the buy and the sell together costs 0.08 ETH.

The result is 3 - 1 - 0.08 = 1.92 ETH of profit on this trade. But the trader also ran the bot on four other launches that week, and three of them never found a second buyer, so those positions were sold at a loss. The profit on one launch only matters when the whole week's trades are counted together.

What are the common mistakes?

The most common mistakes with sniper bots are skipping the safety checks, sizing positions too large and ignoring the legal and tax side.

  • No honeypot check. A token that cannot be sold is worth nothing, however fast the buy was.
  • Position too large. A single launch should never risk more than a small share of the trading budget.
  • No exit rules. A snipe that never sells is just a very fast bag of tokens nobody wants.
  • Slow node connection. A bot on a shared public endpoint will see every launch a block late and lose to faster bots.
  • Ignoring gas. On a busy launch, gas can cost more than the position is worth, so the bot should check the fee before it buys.
  • Ignoring the rules. Front-running and market manipulation are treated differently in different places, and tax on short-term trades varies too, so check the local rules before running a bot.

For the exchange side of the same market, see top DeFi protocols.

Key takeaways

  • A sniper bot's edge is speed at a known moment, not prediction
  • Watch, decide, fire and exit: each stage decides the result
  • Simulate the sell before you buy, or you will buy honeypots
  • Private routing and priority fees fight front-running
  • Pre-set exit rules matter more than the entry
  • Most new tokens go to zero, so size every position to lose

Frequently asked questions

What is a crypto sniper bot?

A crypto sniper bot is an automated program that buys a token the moment it becomes tradable on a decentralised exchange, usually within the same block that liquidity is added. It watches the chain for the launch signal and sends a pre-built buy before human traders react.

How does a sniper bot detect a launch?

It watches for pool-creation events from a DEX factory, watches pending transactions in the mempool for the liquidity transaction, or watches a launchpad's contracts. On chains with a public mempool, the liquidity transaction is visible before it executes.

What is a honeypot token?

A honeypot is a token that can be bought but not sold, because its contract blocks sales or taxes them away. A serious sniper bot simulates a sell against local chain state before buying, which is what catches honeypots.

Do sniper bots work on Solana as well as Ethereum?

Yes. Sniping started on Ethereum and BNB Chain DEXs and spread to Solana launchpads. The mechanics differ: Ethereum bots compete on gas and private routing, while Solana bots compete on raw latency to the validator.

How much money do you need to run a sniper bot?

The trading funds are separate from the gas budget, and both should be small at first. Start with a tiny position size and a daily loss limit, and only raise the size after a week of trades you can explain.

Are sniper bots legal?

It depends on where you are and what the bot does. Front-running and market manipulation are treated differently in different places, and tax on short-term trades varies too. Check the local rules before running a bot.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a trading bot or a DeFi product and need help? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Crypto Exchange service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call