2

I have a friend who got hacked recently. The hacker drained all of the valuable NFTs and ERC-20s out of the wallet. The hacker did leave some NFTs of lower value in the wallet. The victim of the hack is trying to transfer the NFTs out of the wallet but every time he sends Eth to use as gas the hacker has a bot set up that immediately drains the wallet. Is there any way to get a transaction through to rescue some of the NFTs before the bot can drain the wallet? I believe in Bitcoin there's a child pays for parent feature where one transaction can pay another transaction's gas fees. Is there a way to do this in Ethereum? Maybe some type of flash transaction or MEV functionality?

2
  • Build a faster bot. There are many companies proposing such services, and also you can search someone in Fiver or freelancer. Considering that you dont have much experience with solidity.
    – Kaneda
    Commented Oct 23, 2021 at 20:01
  • Pay more fee for trnsaction and get your two transactions be executed faster than bot manages to leak your funds. But that's risky as hacker's bot can pay 99% of the available balance as a fee.
    – rlib
    Commented Sep 17, 2022 at 16:21

2 Answers 2

4

You are in the correct path. MEV can do this for you.

You can use MEV to submit two transactions with the following properties:

  • Either both or none of them go through
  • They should be executed in the same block, next to each other
  • The first one adds Ethers to the wallet
  • The second one transfers the assets out
  • You pay the miners directly in Eth, disregarding any gas fees
  • The transactions are not broadcast publicly, but are sent privately to miner(s)

You can use Flashbots to accomplish this. If the total value of the assets is big enough, you can ask their whitehat hackers for assistance. Or you can do it yourself with their tooling, which requires some developer know-how.

7
  • This sounds like a great idea! I will tell my friend to try it. Is there any way I can get in contact with a mining pool to try to ensure that the transaction remains private until it is mined ensuring that the bot doesn't front run it? Commented Oct 23, 2021 at 20:32
  • There is a service for that, check out Flashbots Commented Oct 24, 2021 at 8:02
  • Oh this is awesome, just confirming that I'm on the correct site... docs.flashbots.net Is this it? This looks really fascinating I'm surprised I haven't heard of it before. This website claims that "The mining pools running MEV-geth collectively account for over 85.5% of total Ethereum hashrate." is that really true? And this protocol allows you to have your transaction mined in secret? Commented Oct 24, 2021 at 10:47
  • That's the right place. Don't know about the percentages nowadays. But, yes, otherwise correct Commented Oct 24, 2021 at 12:10
  • 1
    I actually wrote a blog post about this kind of rescue: medium.com/coinmonks/rescuing-an-nft-fd0acccfa25a Commented Nov 13, 2021 at 7:10
3

I was in the same situation - my credentials were stolen when i connected metamask to scam website that looked like legit one. ETH scavenger was eating all my ETH in wallet and my NFTs were stuck in there. Fortunately i was able to rescue them using Flashbot relay to frontrun bot writing my own script. Basically using flashbots you can create multiple transactions and send them in one bundle with following useful features:

  • bundle is atomic - all transactions will pass or none
  • bundle will be not visible in mempool (aka dark forest) so hacker/bot will see it only if it is included in block and thats too late for him to do anything about it

In my setup i had 3 wallets:

  1. Compromised wallet - owner of NFTs
  2. Safe wallet - i want to transfer my NFTs here
  3. Funding wallet - this one keeps small amount of ETH for gas fees

My bundles looked like this:

  1. Send ETH for gas from Funding to Compromised
  2. Send NFT1 from Compromised to Safe
  3. Send NFT2 from Compromised to Safe
  4. possibly more transactions ...

ETH scavenger was eating all above 0.00525 ETH so i had to make sure there was less than this amount left in my wallet. EDIT: In fact if bot sweeps ETH only if balance exceeds some treshold you might use this to your advantage. Send only small amount of ETH that wont be more than bot treshold. If gas price is favorable you might have enough to pay gas fees for NFT transfer. This way you will be able to rescue your NFTs one by one.

In order to run transactions programatically you will need transaction data. You can see this data when you find NFT contract on etherscan, connect your wallet, see contract tab (write contract), fill in transaction data and just before executing transaction you can see hex transaction data. This hex string you will need in script.

By this approach i was able to save also SOS - ERC20 tokens recently distributed by OpenDAO. Bundle will have to contain also claim transaction before transfer

This will also work if your tokens are staked. You have to call unstake before transfer

If you adjust the script this will also work for claiming strong token from nodes linked to hacked wallet.

This video is great starting point https://www.youtube.com/watch?v=1ve1YIpDs_I

EDIT: adding a repo with script i have used

Not the answer you're looking for? Browse other questions tagged or ask your own question.