Superset of Flashbots' plugin for Web3.py allowing bundles to be submitted to many miners.
Project description
Web3 More Bundlers
This library works by injecting flashbots (bundler
) 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
.
This is a superset project of Flashbot's package for Web3.py, and originally adapted from TitanBuilder's PR (flashbots/web3-flashbots#76). Flashbots currently only supports Web3.py version ^5.22.0 (not >=6).
Quick Start
Installing
Currently, this is not a published packaged, and is easiest to install using Poetry (pipx). But, any package/env management solution that can install from Git/Github will work.
poetry add git+https://github.com/vile/web3-more-bundlers
Example
import os
from eth_account.account import Account
from eth_account.signers.local import LocalAccount
from web3 import HTTPProvider, Web3
from web3morebundlers import bundler
ETH_ACCOUNT_SIGNATURE: LocalAccount = Account.from_key(os.environ.get("ETH_SIGNER_KEY"))
BUNDLER_ENDPOINTS = ["https://relay.flashbots.net", "https://rpc.titanbuilder.xyz", ...]
w3 = Web3(HTTPProvider("http://localhost:8545"))
bundler(w3=w3, signature_account=ETH_ACCOUNT_SIGNATURE, endpoint_uris=BUNDLER_ENDPOINTS)
Now the w3.flashbots.sendBundle
method should be available to you. Look in examples/simple.py for usage examples.
Using Testnets
Currently, the base flashbots package only supports Goerli. To use Goerli, add the Goerli relay RPC to the bundler
function arguments.
bundler(w3=w3, signature_account=ETH_ACCOUNT_SIGNATURE, endpoint_uris=BUNDLER_ENDPOINTS, flashbots_uri="https://relay-goerli.flashbots.net")
Migrating
Switching from the base Flashbots package to web3morebundlers is simple. This package initializes flashbot
under the hood and exposes all existing w3.flashbot
functions; only the initializer function needs to be changed (with an additional param).
Let's migrate flashbot's quickstart example:
from eth_account.signers.local import LocalAccount
from web3 import Web3, HTTPProvider
- from flashbots import flashbot
+ from web3morebundlers import bundler
from eth_account.account import Account
import os
ETH_ACCOUNT_SIGNATURE: LocalAccount = Account.from_key(os.environ.get("ETH_SIGNER_KEY"))
+ BUNDLER_ENDPOINTS = ["https://relay.flashbots.net", "https://rpc.titanbuilder.xyz", ...]
w3 = Web3(HTTPProvider("http://localhost:8545"))
- flashbot(w3, ETH_ACCOUNT_SIGNATURE)
+ bundler(w3=w3, signature_account=ETH_ACCOUNT_SIGNATURE, endpoint_uris=BUNDLER_ENDPOINTS)
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 web3morebundlers-0.1.1.tar.gz
.
File metadata
- Download URL: web3morebundlers-0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fbccd548e2acfe8cf3b6cf2b76cec3cdb61c6674d4333ec874e7a8d1dfadcf7 |
|
MD5 | eb8e644ed904b75c0b62aa49e64f3766 |
|
BLAKE2b-256 | cc63a2eba367c6d9417272966256376e881e75449b0182ef89cfab5c07a9722d |
File details
Details for the file web3morebundlers-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: web3morebundlers-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39d3ee9d8140c0b244653719ad06960d7a6d506cede1584c193c80a0b8caea2b |
|
MD5 | e934cae26a4f2c72f6451278c2fb1ea5 |
|
BLAKE2b-256 | 86a1b4742ac26beeb9527c591b57764f07b2326893c6cea5e06d670e4191c483 |