Skip to main content

This library works by injecting flashbots as a new module in the Web3.py instance, which allows submitting "bundles" of transactions directly to miners. This is done by also creating a middleware which captures calls to eth_sendBundle and eth_callBundle, and sends them to an RPC endpoint which you have specified, which corresponds to mev-geth.

To apply correct headers we use the flashbot method which injects the correct header on POST.

Quickstart

from eth_account.signers.local import LocalAccount
from web3 import Web3, HTTPProvider
from flashbots import flashbot
from eth_account.account import Account
import os

ETH_ACCOUNT_SIGNATURE: LocalAccount = Account.from_key(os.environ.get("ETH_SIGNATURE_KEY"))


w3 = Web3(HTTPProvider("http://localhost:8545"))
flashbot(w3, ETH_ACCOUNT_SIGNATURE)

Now the w3.flashbots.sendBundle method should be available to you. Look in examples/simple.py for usage examples.

Testnet

To use an ethereum testnet, add the appropriate testnet relay RPC to the flashbot function arguments.

flashbot(w3, ETH_ACCOUNT_SIGNATURE, "https://relay-holesky.flashbots.net")

Check flashbots docs for up-to-date URLs.

Development and testing

Install poetry

Poetry will automatically fix your venv and all packages needed.

poetry install

Tips: PyCharm has a poetry plugin

Simple Testnet Example

See examples/simple.py for environment variable definitions.

poetry shell
ETH_SENDER_KEY=<sender_private_key> \nPROVIDER_URL=https://eth-holesky.alchemyapi.io/v2/<alchemy_key> \nETH_SIGNER_KEY=<signer_private_key> \npython examples/simple.py

Linting

It's advisable to run black with default rules for linting

sudo pip install black # Black should be installed with a global entrypoint
black .

Metadata

Release files for flashbots 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flashbots 2.0.0
File Size Uploaded
flashbots-2.0.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flashbots 2.0.0
File Interpreter ABI Platform
flashbots-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.5 kB

Release files / flashbots-2.0.0.tar.gz

Download URL flashbots-2.0.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
dc4a28905a545ea1e69a1411e63419b72c2b8bacd2d385cce75a4a9921d65635
BLAKE2b-256 checksum
How to use checksums
2626581de75c06b28fb2072e8efcdbcca0d01c63fab8072d4b4497b5cba9e0e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release files / flashbots-2.0.0-py3-none-any.whl

Download URL flashbots-2.0.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64f09f6fbb1ba97d8d0ca307bcc204f734a24d01ea59ce94037510d539c737b3
BLAKE2b-256 checksum
How to use checksums
996b9c309eb0b43ef0f773ba5561a7e1bb33960a926ee8cfbd2cb5667c9b9a9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page