Front-Running
Front-running is an attack where a malicious actor observes a pending transaction in the mempool and submits their own transaction with a higher gas price to execute first, profiting at the victim's expense.
In Depth
Front-running exploits the transparency of blockchain mempools, where pending transactions are visible before being included in a block. An attacker (or MEV bot) monitors the mempool for profitable opportunities, then submits a competing transaction with higher gas to be mined first. The most common form is the sandwich attack, where the attacker front-runs a large swap to move the price, lets the victim's trade execute at a worse price, and then back-runs to profit from the price difference. Mitigations include commit-reveal schemes, private transaction pools like Flashbots Protect, and protocol-level designs that minimize MEV extraction such as batch auctions and encrypted mempools.
Frequently Asked Questions
What is front-running in crypto?
Front-running is when someone sees your pending transaction in the mempool and gets their own transaction executed first by paying higher gas. In DeFi, this often takes the form of sandwich attacks on swaps, where the attacker profits from the price movement caused by your trade.
What is MEV and how does it relate to front-running?
MEV (Maximal Extractable Value) is the profit that block producers or searchers can extract by reordering, inserting, or censoring transactions within a block. Front-running is one of the primary MEV extraction strategies, alongside back-running, sandwich attacks, and arbitrage.
How can protocols mitigate front-running?
Protocols can use commit-reveal schemes (hide transaction details until committed), private transaction submission via Flashbots Protect, batch auctions that process all orders at the same price, and protocol designs that minimize extractable value such as oracle-based pricing instead of AMM spot prices.