Front-running on a public blockchain is the practice of observing a pending transaction in the mempool and submitting your own transaction with a higher priority fee to be mined first.
In DeFi, front-running is a profitable strategy because pending transactions reveal information: a large swap will move the price, a large mint will alter token supply, an oracle update will reprice positions. Front-running is one component of the broader phenomenon known as MEV.
Defenses include:
- Private mempools (Flashbots Protect, MEV Blocker) that don't broadcast transactions publicly.
- Commit-reveal schemes that hide the transaction's content until it's mined.
- Slippage protection in swap UIs to bound the worst-case execution price.
- Batched auctions (e.g., CoW Swap) that match orders at a single uniform price.
Front-running is not strictly an attack, it's a property of public blockchains. The question is whether your users are exposed to it without compensation.