A Python script that uses Flashbots to create Ethereum transaction bundles. Based off of Flashbots' Python library example.
- Git - Install Git
- Check if you have Git installed with
git --version
- Check if you have Git installed with
- Python (>=3.10; <4) - Install Python (Windows), Install Python (Linux)
- Check if you have Python installed with
python3 --version
- Check if you have Python installed with
- Pip - Install Pip
- Check if you have Pip installed with
pip --version
- Check if you have Pip installed with
- Poetry - Install Poetry (preferrably with pipx)
- Check if you have Poetry installed with
poetry --version
- Check if you have Poetry installed with
git clone https://github.com/vile/flashbots-recovery-py.git
cd flashbots-recovery-py
make deps
mv .env.example .env
Include your Alchemy API key, compromised & gasser private keys, and recovery wallet address.
make start
git clone https://github.com/vile/flashbots-recovery-py.git
cd flashbots-recovery-py
- At the top right of the repo on GitHub, click the green
Code
button, then underHTTPS
clickDownload ZIP
. - Extract the downloaded archive to a folder like your Desktop using any ZIP tool (such as WinRAR, 7Zip, or NanaZip).
- Navigate to the extracted folder.
poetry install --no-root
Remove the .example
file extension from the .env.example
file.
Include your Alchemy API key, compromised & gasser private keys, and recovery wallet address.
poetry run py main.py
In most cases, two seperate wallets are required to complete a rescue: a wallet that provides ETH for gas fees (the "gasser" wallet), and the wallet in which assets are being recovered from (the "compromised" wallet). Providing ETH from a secondary wallet in the same bundle elimates issues with sweeper bots.
A transaction bundle is atomic, meaning the bundle will only be mined if all the transactions within the bundle will execute successfully in the same block.
A simple and generic ETH transfer transaction already exists in bundle.py.
Most of the time, you will only need to change the value
(amount) of ETH sent (default: 0.01
ETH).
However, if there is a case where the gasser wallet needs to execute multiple transaction before the compromised wallet, it is extensible.
Transactions in compromised_wallet_txs
completely depend on what interactions are required to rescue assets.
Generic (partial) ABIs are provided for all major ERCs (ERC721, ERC1155, and ERC20), along with a generic batch transfer contract.
In the case where transactions interact with non-ERC-conforming tokens or custom contracts, you can either put your own ABI in utils.abi, or manually construct the calldata and include it in the data
field of the tx.
As each entry in compromised_wallet_txs
is executed seperately, every new transaction needs to have a properly incremented nonce attached to it.
Incrementing Nonce Between Transactions
# transaction 1
{
...
"nonce": w3.eth.get_transaction_count(
constants.ETH_COMPROMISED_ACCOUNT_SIGNER.address
),
...
},
# transaction 2
{
...
"nonce": w3.eth.get_transaction_count(
constants.ETH_COMPROMISED_ACCOUNT_SIGNER.address
) + 1,
...
}
Examples are viewable under the examples folder.