- The problem: One of your wallets has been compromised, and any ETH you put on ther is siphoned off immediately. You would like to retrieve some assets or transfer contract ownership, but that all costs gas and your gas tank is stuck on empty.
- The solution: Flashbots!
- The code for this repo provides an example of how
- This is the actual code I used (with added comments) to recover assets from a compromised wallet
- Most of the code comes from the original repository
- Run
npm install
- Create an account at a node service provider: Infura is used in this example.
- Construct a list of transactions. You can get the gasLimit and tx data by doing a dry run with metamask and/or etherscan
- Test out on Goerli testnet (if possible)
- Prepare a mainnet wallet which has just enough Ethers for the bundle, and no other assets
Pass everything in as environment variables, like so:
INFURA_KEY=<...> FUNDING_WALLET_PRIVATE_KEY=<...> COMPROMISED_WALLET_PRIVATE_KEY=<...> npm run start
. Remember- For example:
INFURA_KEY='blah' FUNDING_WALLET_PRIVATE_KEY='abc' COMPROMISED_WALLET_PRIVATE_KEY='def' npm run start
Either modify the script to use the dotenv package or carefully insert the data manually in the script. NEVER EVER UPLOAD THE SCRIPT WITH THE PRIVATE DATA ANYWHERE ONLINE