_Follow along with this video:_ --- ### MEV - LIVE > ❗ **IMPORTANT** > The true value in this (and the following lesson) is found in seeing this exploit in action. If you're unable to watch this currently, I encourage you to return when you can! Here is [the code we are going to use to see it](https://github.com/Cyfrin/sc-exploits-minimized/blob/main/src/MEV/Frontran.sol) ```javascript // SPDX-License-Identifier: MIT pragma solidity 0.8.20; contract FrontRan { error BadWithdraw(); bytes32 public s_secretHash; event success(); event fail(); constructor(bytes32 secretHash) payable { s_secretHash = secretHash; } function withdraw(string memory password) external payable { if (keccak256(abi.encodePacked(password)) == s_secretHash) { (bool sent,) = msg.sender.call{value: address(this).balance}(""); if (!sent) { revert BadWithdraw(); } emit success(); } else { emit fail(); } } function balance() external view returns (uint256) { return address(this).balance; } } ``` Watch the video to see: 1. Me get front-ran 2. How we prevent it with [Flashbots Protect](https://docs.flashbots.net/flashbots-protect/overview)
Patrick demonstrates himself getting front ran in a recording of a live example.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Solidity Developer
Smart Contract SecurityDuration: 25min
Duration: 1h 18min
Duration: 35min
Duration: 2h 16min
Duration: 5h 03min
Duration: 5h 22min
Duration: 4h 33min
Duration: 2h 01min
Duration: 1h 40min
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar