on flashbots auctions in 5 minutes

tl; dr

today i go over a PoC to send MEV bundles through flashbots.


🎶 today’s mood


flashbots auction

A private communication channel (RPC endpoint) between miners and searchers for transparent and efficient MEV extraction through:

  • mev-geth: a patch on top of go-ethereum client

  • mev-relay: a transaction bundle relayer

Why is this important? Okay, so in the regular Ethereum transaction pool:

  1. users broadcast transactions to the public peer-to-peer network and specify a gas price (how much they are willing to pay for each unit of computation on the Ethereum chain).

  2. miners receive these transactions, order them by gas price, and use a greedy algorithm to produce a block that maximizes the value received through transaction fees.

With Flashbots Auction, however, users have access to a first-price sealed-bid auction which allows them to privately communicate their bid and granular transaction order preference without paying for failed bids.

This is how the game works:

  1. Flashbots connects searchers to miners and allows them to avoid the public tx pool.

  2. Searchers craft "bundles" with transactions they would like to send miners, and send them to Flashbots' MEV-Relay.

  3. mev-relay is a gateway that Flashbots runs which simulates searchers' bundles, and if there are no errors, then forwards them on to miners.

  4. Miners then receive bundles and include them in blocks if it is profitable for them to do so.


💡 Enough of bla bla bla, let’s get some code going.


poc of how flashbots works (goerli)

Before you run the PoC I wrote, you need:

  1. Two test accounts on Ethereum (for instance, you can create them on Metamask). Take note of their private keys: one will be an empty wallet for signing/reputation, and the other will hold funds.

  2. An Alchemy account, then take note of a provider’s URL+KEY for Goerli.

  3. Some imaginary Goerli (fake) money from some faucet, like this one for example.

  4. Install the required Python 3 packages on a virtual environment, as described here, then add the info above into a .env file.

You are ready to run your first Flashbots bundle.

The script below sends a bundle of two transactions that transfer Goerli ETH into a random account:

Running this code should print something like this:

Submitting a simple bundle with Flashbots.
Submitting a simple bundle with Flashbots.

◻️ motherofbots.eth

Subscribe to bt3gl's autistic symposium
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.