Skip to main content

No project description provided

Project description

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 .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_aea_flashbots-2.1.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_aea_flashbots-2.1.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file open_aea_flashbots-2.1.0.tar.gz.

File metadata

  • Download URL: open_aea_flashbots-2.1.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for open_aea_flashbots-2.1.0.tar.gz
Algorithm Hash digest
SHA256 65a4e39615d59f96c8d6254cc6f7f9568f3e0253c66da8ff9042b1f51c80e494
MD5 c7711e3e1446df4824f659887e48b4a8
BLAKE2b-256 939d3fbd4523e74c063ee54d035640d213c769e6a48e2f0c332b0b265628ded3

See more details on using hashes here.

File details

Details for the file open_aea_flashbots-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for open_aea_flashbots-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce58aa721fb58ca1da97e5f135218c2451922847f1b707412357cf2ff7eefb2
MD5 d337c571d036b52de5894294148dde5b
BLAKE2b-256 3678a6cb030fc689c0632c200bd56a8c852d5b6144811958775c9bb9faece403

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page