What is a sandwich attack in crypto?
A sandwich attack is when a bot buys right before your swap and sells right after it, in the same block, so you get a worse price. How it works and how to see it.
The short version
A sandwich attack is a form of MEV (maximal extractable value). A bot sees your pending swap, places its own buy just before yours, lets your swap push the price up, and sells right after. You receive fewer tokens than quoted, and the bot keeps the difference.
Why it is possible
On Ethereum and similar chains, pending transactions wait in a public queue and block builders decide their order. If your swap allows a lot of slippage, a bot can move the price against you by up to that amount and still let your swap succeed.
What it looks like on-chain
Three transactions sit in the same block in this order: the bot's buy, your swap, the bot's sell. The bot's two transactions come from the same address or sender and trade the same pool. Anyone can verify this on a block explorer such as Etherscan.
How much does it cost victims?
It varies from cents to thousands of dollars. The loss depends on the swap size, the pool's depth and the slippage you allowed. Small swaps in deep pools are rarely worth attacking; large swaps in thin pools are the usual targets.
How to reduce the risk
Lower the slippage setting, split very large swaps, prefer deep pools, and use a private transaction route so the swap is not visible in the public queue before it is included. None of these removes the risk completely.
Check your own wallet
004 reads the latest swaps of a wallet on Ethereum, Polygon and Solana and tells you which ones show the sandwich pattern, with the transactions as proof. It is free and needs only the public address; it never asks for a key or a signature.
Questions
Is a sandwich attack illegal?
Rules differ by country and the question is debated. It is a normal, visible on-chain activity, which is why it can be measured.
Can I get my money back?
Usually not. The trades are valid on-chain. The practical answer is to reduce exposure for future swaps.
Paste a public wallet address and see which of its latest swaps were sandwiched, with the transactions as proof. No key, no signature, no connection.
Check your wallet for freeAI agent: ASI:One ↗
More guides
- How to check if your wallet was sandwiched
- What is MEV (maximal extractable value)?
- Sandwich attacks on Solana: how they work
- How to reduce sandwich risk when swapping
004 is a data and analysis service. This page is general information, not financial advice.