diff --git a/.gitignore b/.gitignore index ac1ef8a..efc9c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ __pycache__ *.pyc .idea +build/ +dist/ +flashbots.egg-info/ diff --git a/PKG-INFO b/PKG-INFO new file mode 100644 index 0000000..b85d544 --- /dev/null +++ b/PKG-INFO @@ -0,0 +1,62 @@ +Metadata-Version: 2.1 +Name: flashbots +Version: 1.0.0 +Summary: flashbots client +Author: Georgios Konstantopoulos +Author-email: me@gakonst.com +Requires-Python: >=3.9,<4.0 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.9 +Requires-Dist: web3 (>=5.22.0,<6) +Description-Content-Type: text/markdown + +This library works by injecting 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 FlashbotProvider which injects the correct header on post. + +## Example + +```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` for usage examples + +# Development and testing + +Setup and run (mev-)geth with Websocket support: + +```sh +geth --http --http.api eth,net,web3,txpool --syncmode full +``` + +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 + +## 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 . +``` diff --git a/README.md b/README.md index 311d0c4..e90eb7c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ +# web3-flashbots -This library works by injecting a new module in the Web3.py instance, which allows +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 FlashbotProvider which injects the correct header on post +them to an RPC endpoint which you have specified, which corresponds to `mev-geth`. + +To apply correct headers we use FlashbotProvider which injects the correct header on post. ## Example @@ -23,27 +25,29 @@ flashbot(w3, ETH_ACCOUNT_SIGNATURE) Now the `w3.flashbots.sendBundle` method should be available to you. Look in `examples/simple.py` for usage examples -# Development and testing +## Development and testing Setup and run (mev-)geth with Websocket support: -``` + +```sh geth --http --http.api eth,net,web3,txpool --syncmode full ``` Install [poetry](https://python-poetry.org/) -Poetry will automatically fix your venv and all packages needed -``` +Poetry will automatically fix your venv and all packages needed. + +```sh poetry install ``` -Tips: PyCharm has a poetry plugin +Tips: PyCharm has a poetry plugin ## 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 . ``` - diff --git a/pyproject.toml b/pyproject.toml index 109295e..295d646 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] authors = ["Georgios Konstantopoulos ", "Nikolas Papaioannou "] name = "flashbots" -version = "1.0.1" +version = "1.0.0" description = "" readme = "README.md" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..43813ac --- /dev/null +++ b/setup.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from setuptools import setup + +packages = \ +['flashbots'] + +package_data = \ +{'': ['*']} + +install_requires = \ +['web3>=5.22.0,<6'] + +setup_kwargs = { + 'name': 'flashbots', + 'version': '1.0.0', + 'description': 'web3-flashbots.py', + 'long_description': '\nThis library works by injecting a new module in the Web3.py instance, which allows\nsubmitting "bundles" of transactions directly to miners. This is done by also creating\na middleware which captures calls to `eth_sendBundle` and `eth_callBundle`, and sends\nthem to an RPC endpoint which you have specified, which corresponds to `mev-geth`. \nTo apply correct headers we use FlashbotProvider which injects the correct header on post \n\n## Example\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` for usage examples\n\n# Development and testing\n\nSetup and run (mev-)geth with Websocket support:\n```\ngeth --http --http.api eth,net,web3,txpool --syncmode full\n```\n\nInstall [poetry](https://python-poetry.org/)\n\nPoetry will automatically fix your venv and all packages needed\n```\npoetry install\n```\nTips: PyCharm has a poetry plugin\n\n\n## Linting\nIt\'s advisable to run black with default rules for linting\n\n```\nsudo pip install black # Black should be installed with a global entrypoint\nblack .\n```\n\n', + 'long_description_content_type': 'text/markdown', + 'author': 'Georgios Konstantopoulos', + 'author_email': 'me@gakonst.com', + 'maintainer': None, + 'maintainer_email': None, + 'url': None, + 'packages': packages, + 'package_data': package_data, + 'install_requires': install_requires, + 'python_requires': '>=3.9,<4.0', +} + + +setup(**setup_kwargs)