/flashbot-compromised

Primary LanguageTypeScriptMIT LicenseMIT

Flashbot recovery example

  • See my answer on StackExchange for some background - https://ethereum.stackexchange.com/a/119360/91977

  • 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 this code was taken from the example provided by https://www.youtube.com/watch?v=1ve1YIpDs_I

Setup

  • npm install
  • 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 (youll have to request goerli ETH and testing NFT using faucet first. You can use paradigm multifaucet https://faucet.paradigm.xyz/)
  • Run on mainnet

Usage

Simulation - only dry run - this will not execute transaction processing only to see if everything is set up correctly INFURA_KEY=<infura_key> FUNDING_WALLET_PRIVATE_KEY=<funding_PK> COMPROMISED_WALLET_PRIVATE_KEY=<compromised_PK> npm run start

Run bundle - this will execute bundle INFURA_KEY=<infura_key> FUNDING_WALLET_PRIVATE_KEY=<funding_PK> COMPROMISED_WALLET_PRIVATE_KEY=<compromised_PK> SEND_BUNDLE=true npm run start

  • !!! DON'T EVEN THINK ABOUT PUTTING YOUR PRIVAT KEYS IN A JSON FILE !!!
  • Also, keep your funding wallet lean. Definitely don't store a lot of crypto + NFTs in it.
  • If you absolutely must put your keys in a file, then name the file secrets.json, which is included in this repo's .gitignore

Sources

Flashbots