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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file open_aea_flashbots-1.4.0.tar.gz
.
File metadata
- Download URL: open_aea_flashbots-1.4.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d026f4af9543bed85ee7443e9041e257ade8c06eefd64bd1a38dcb24692849d4 |
|
MD5 | 1e0518af26b3034e2d8098fd001ea5d3 |
|
BLAKE2b-256 | b3e7cbdcea59ad43a2cb8ff9fc702139d7549e8cd6a22d400534d3ec05a0f2c1 |
File details
Details for the file open_aea_flashbots-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: open_aea_flashbots-1.4.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a22e129d2fe01546bbd46f3a7f7c1212fc1e0810b5eca8e37152fb34ee99d6 |
|
MD5 | d6688f7493eb6f2b516285973b386cf3 |
|
BLAKE2b-256 | 2d044ba71815df0eac2dc202b883094f50c981c0deae030b885f4994269405bb |