UNSWEEP › Guides

Sweeper bot on a hacked wallet: why sending gas is risky and how a one-transaction rescue works

This guide is informational. Funds already moved out of a compromised wallet cannot be recovered. A rescue can only try to move assets that are still in the wallet, and it is not guaranteed to succeed.

Check any address first with the free, read-only diagnostic: https://unsweep.com/ (no keys, no signatures).

Current scope of UNSWEEP: Base: 16 verified tokens. Arbitrum: 12 verified tokens. Other ERC-20 tokens may be detected, but without any guarantee. Ethereum: read-only diagnostic only (no rescue). Funds already taken cannot be recovered, and NFTs are not rescued. See what can and cannot be rescued and the step-by-step rescue guide. Start with the free diagnostic.

What a sweeper bot is

A wallet (an externally-owned account, EOA) is controlled by whoever has its private key. Ethereum's documentation describes an EOA as “controlled by anyone with the private keys” and says the private key “is what you use to sign transactions, so it grants you custody over the funds associated with your account” (ethereum.org – Accounts).

When an attacker obtains that key, the attacker can sign transactions from the wallet exactly as the owner can. A sweeper bot is an automated program run by the attacker that watches the compromised address and tries to sign a transfer out as soon as value arrives. The network cannot tell the owner and the attacker apart: both hold a valid key.

Why sending gas to a compromised wallet is risky

Every transaction must pay a fee in ETH. Per Ethereum's documentation: “Gas fees have to be paid in Ethereum's native currency, ether (ETH)”, and the sender is “the externally owned account that sends the transaction, pays for gas” (ethereum.org – Gas).

So to move tokens out of the wallet in the usual way, the owner must first send ETH to it. That ETH is exactly what the sweeper is waiting for. The attacker can also bid for ordering: “tips allow users to outbid others for priority within the same block” and “a higher tip can make it more likely that your transaction will get into the next block” (ethereum.org – Gas). A higher tip improves the chance of earlier inclusion; it does not guarantee that the attacker's transfer runs first or instantly. Even so, any ETH that lands in the wallet can be spent by whoever holds the key, so the attacker may take it before the owner's token transfer uses it. That is why sending ETH for gas to a swept wallet is not recommended.

How a one-transaction rescue works

The idea is to never put ETH in the compromised wallet. EIP-7702 (status: Final) lists among its motivations:

EIP-7702 adds a transaction type (SET_CODE_TX_TYPE = 0x04) carrying an authorization_list of tuples [chain_id, address, nonce, y_parity, r, s]. The account that is delegated is recovered from the signature: “Let authority = ecrecover(msg, y_parity, r, s)” (EIP-7702 – Specification). This means:

  1. The owner of the compromised wallet signs an authorization locally, on their own device. The private key is never shared or uploaded.
  2. A separate, clean account submits the type-0x04 transaction and pays the gas. The compromised wallet receives no ETH, so there is nothing for the sweeper to take.
  3. Inside that single atomic transaction, the delegated code moves the remaining tokens to a safe address chosen by the owner. If execution fails, the token transfers in it are undone, but an authorization that was already processed is not rolled back: the wallet can remain delegated even after a failed rescue, so a failed attempt is not evidence that the wallet has no delegation. Check the wallet's code again afterwards (EIP-7702 – Behavior).

Limits to be aware of: the attacker still holds the key and can sign their own transactions, including their own authorizations, so the outcome is a race that is not guaranteed. This only works on networks where EIP-7702 is active, and only for assets that are still in the wallet.

Before anything else

Start with the free diagnostic to see what is still in the wallet and whether a delegation is set: https://unsweep.com/.

Related: Malicious EIP-7702 delegation: detect and revoke · Compromised wallet checklist

Sources: EIP-7702 · ethereum.org Accounts · ethereum.org Gas

Related guides: Why ETH sent for gas gets stolen immediately · Rescue USDC and WETH from a hacked wallet on Base · Rescue tokens from a hacked wallet on Arbitrum · Sweeper bot vs malicious EIP-7702 delegation · How to check if a wallet has a sweeper bot · What to do in the first 5 minutes after a wallet hack · Malicious EIP-7702 delegation · Step-by-step rescue · What can and cannot be rescued
MetaMask is a trademark of its owner, referenced descriptively; UNSWEEP is not affiliated with MetaMask or Consensys.

Before you start: trust facts

Sounds familiar? “My funds disappear as soon as they arrive” · “I can’t pay for gas because the ETH is taken instantly” · “My wallet was hacked and I can’t get my tokens out”.