Skip to main content

web3-flashbots

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_SIGNER_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.

Goerli

To use goerli, add the goerli relay RPC to the flashbot function arguments.

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

Development and testing

Install poetry

Poetry will automatically fix your venv and all packages needed.

poetry install

Tips: PyCharm has a poetry plugin

Simple Goerli Example

See examples/simple.py for environment variable definitions.

poetry shell
ETH_SENDER_KEY=<sender_private_key> \
PROVIDER_URL=https://eth-goerli.alchemyapi.io/v2/<alchemy_key> \
ETH_SIGNER_KEY=<signer_private_key> \
python 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 open-aea-flashbots 2.1.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 open-aea-flashbots 2.1.0
File Size Uploaded
open_aea_flashbots-2.1.0.tar.gz 7.9 kB Details

Built distribution (wheel)

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

Total release size: 17.9 kB

Release files / open_aea_flashbots-2.1.0.tar.gz

Download URL open_aea_flashbots-2.1.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
65a4e39615d59f96c8d6254cc6f7f9568f3e0253c66da8ff9042b1f51c80e494
BLAKE2b-256 checksum
How to use checksums
939d3fbd4523e74c063ee54d035640d213c769e6a48e2f0c332b0b265628ded3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / open_aea_flashbots-2.1.0-py3-none-any.whl

Download URL open_aea_flashbots-2.1.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ce58aa721fb58ca1da97e5f135218c2451922847f1b707412357cf2ff7eefb2
BLAKE2b-256 checksum
How to use checksums
3678a6cb030fc689c0632c200bd56a8c852d5b6144811958775c9bb9faece403
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.0

1 release file

1.2.0

1 release file

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