Simple Solidity smart contract to test frontruns on Ethereum.
Using https://emn178.github.io/online-tools/keccak_256.html or similar.
Deploy the contract to a testnet or mainnet, and pass the hash output generated in step 1 as the first parameter in the contract constructor, along with an optional amount of Ether.
The amount has to be big enough to attract front runners (look at gas prices).
Now we're ready to get front run. Call the smart contract's take()
function, and pass the raw input you used to generate the hash as the parameter.
Send the transaction, and take a look at your smart contract on EtherScan.
Now you'll see multiple attempts to retrieve the funds and your contract should be drained of Ether, since your transaction has been front run by other peers.