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
```python
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](./examples/simple.py) for usage examples.
### Goerli
To use goerli, add the goerli relay RPC to the `flashbot` function arguments.
```python
flashbot(w3, ETH_ACCOUNT_SIGNATURE, "https://relay-goerli.flashbots.net")
```
## Development and testing
Install [poetry](https://python-poetry.org/)
Poetry will automatically fix your venv and all packages needed.
```sh
poetry install
```
Tips: PyCharm has a poetry plugin
## Simple Goerli Example
See [examples/simple.py](./examples/simple.py) for environment variable definitions.
```sh
poetry shell
ETH_SENDER_KEY=<sender_private_key> \nPROVIDER_URL=https://eth-goerli.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
```sh
sudo pip install black # Black should be installed with a global entrypoint
black .
```
Raw data
{
"_id": null,
"home_page": "https://github.com/valory-xyz/web3-flashbots",
"name": "open-aea-flashbots",
"maintainer": "zeroXbrock",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "brock@flashbots.net",
"keywords": "",
"author": "Georgios Konstantopoulos",
"author_email": "me@gakonst.com",
"download_url": "https://files.pythonhosted.org/packages/8d/2b/3f980966ae41ef5b06d72b30fc6dd8df4e435728a9e1ea9af689f9a639b9/open-aea-flashbots-1.3.0.tar.gz",
"platform": null,
"description": "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`.\n\nTo apply correct headers we use the `flashbot` method which injects the correct header on POST.\n\n## Quickstart\n\n```python\nfrom eth_account.signers.local import LocalAccount\nfrom web3 import Web3, HTTPProvider\nfrom flashbots import flashbot\nfrom eth_account.account import Account\nimport os\n\nETH_ACCOUNT_SIGNATURE: LocalAccount = Account.from_key(os.environ.get(\"ETH_SIGNATURE_KEY\"))\n\n\nw3 = Web3(HTTPProvider(\"http://localhost:8545\"))\nflashbot(w3, ETH_ACCOUNT_SIGNATURE)\n```\n\nNow the `w3.flashbots.sendBundle` method should be available to you. Look in [examples/simple.py](./examples/simple.py) for usage examples.\n\n### Goerli\n\nTo use goerli, add the goerli relay RPC to the `flashbot` function arguments.\n\n```python\nflashbot(w3, ETH_ACCOUNT_SIGNATURE, \"https://relay-goerli.flashbots.net\")\n```\n\n## Development and testing\n\nInstall [poetry](https://python-poetry.org/)\n\nPoetry will automatically fix your venv and all packages needed.\n\n```sh\npoetry install\n```\n\nTips: PyCharm has a poetry plugin\n\n## Simple Goerli Example\n\nSee [examples/simple.py](./examples/simple.py) for environment variable definitions.\n\n```sh\npoetry shell\nETH_SENDER_KEY=<sender_private_key> \\nPROVIDER_URL=https://eth-goerli.alchemyapi.io/v2/<alchemy_key> \\nETH_SIGNER_KEY=<signer_private_key> \\npython examples/simple.py\n```\n\n## Linting\n\nIt's advisable to run black with default rules for linting\n\n```sh\nsudo pip install black # Black should be installed with a global entrypoint\nblack .\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "web3-flashbots.py",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/valory-xyz/web3-flashbots"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d2b3f980966ae41ef5b06d72b30fc6dd8df4e435728a9e1ea9af689f9a639b9",
"md5": "cbdcdd30fb63b349f9e97abc61c56d63",
"sha256": "b72493faaf76ee9e7a86e8d771b938d8a6a9c7e3c8b2eb10f2a53699a0e3c91d"
},
"downloads": -1,
"filename": "open-aea-flashbots-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "cbdcdd30fb63b349f9e97abc61c56d63",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 10070,
"upload_time": "2023-08-03T07:35:36",
"upload_time_iso_8601": "2023-08-03T07:35:36.609528Z",
"url": "https://files.pythonhosted.org/packages/8d/2b/3f980966ae41ef5b06d72b30fc6dd8df4e435728a9e1ea9af689f9a639b9/open-aea-flashbots-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-03 07:35:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "valory-xyz",
"github_project": "web3-flashbots",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "open-aea-flashbots"
}