Front-running is when an attacker observes a pending transaction in the mempool and submits their own transaction with a higher gas fee to get executed first, profiting from the price movement caused by the original transaction. In crypto, this practice has evolved into an entire industry known as MEV extraction.
How Front-Running Works
The Mempool Advantage
Before transactions are included in a block, they sit in the mempool — a public waiting room visible to everyone. Searchers and bots monitor the mempool 24/7 looking for profitable opportunities.
1. User submits a large buy order (visible in mempool)
2. Bot detects the order and calculates potential profit
3. Bot submits its own buy order with higher gas price
4. Miner/validator includes bot's transaction first
5. User's transaction executes at a worse price
6. Bot sells immediately for a profit
Copy link
MEV Extraction
Maximal Extractable Value (MEV) refers to the total value that can be extracted from block production beyond standard block rewards. Front-running is a primary MEV strategy.
Competing to liquidate undercollateralized DeFi positions
Arbitrage
Exploiting price differences across DEXes
Sandwich Attacks
The Most Profitable Front-Running Variant
A sandwich attack wraps a victim's transaction between two attacker transactions — a buy before and a sell after.
1. Victim submits a swap: 10 ETH for USDC on Uniswap
2. Attacker sees the pending transaction in mempool
3. Attacker buys the same token first (front-run) - price rises
4. Victim's swap executes at the inflated price
5. Attacker sells immediately (back-run) at the higher price
6. Attacker pockets the difference; victim overpays
Copy link
Impact on Regular Traders
Sandwich attacks affect every DEX user. Studies show that sandwich attacks extract millions of dollars per month from unsuspecting traders on Ethereum alone.
Slippage tolerance settings can limit but not eliminate risk