Sweeper Bots Explained: Why Sending Gas to a Compromised Wallet Fails
When an attacker gains a private key, automated programs monitor the address to steal incoming native tokens instantly. Rescuing trapped tokens requires bypassing public mempools entirely.
Key points
- Sweeper bots are automated scripts that monitor mempools to immediately confiscate native gas sent to compromised addresses.
- Compromised wallets holding unbonded staked assets or NFTs cannot move them without native gas, creating a deadlock for victims.
- Manual transactions cannot outpace bots, which automatically submit higher priority fees to ensure their transactions confirm first.
- Trapped tokens can only be recovered using private transaction bundles that bypass the public mempool and execute atomically.
When a crypto wallet's private key is leaked, victims often discover that non-native assets—such as staked tokens, liquidity positions, or non-fungible tokens—remain trapped inside the address. Attempting to fund the account with native tokens like ether ($ETH) or sol ($SOL) to pay transaction fees inevitably fails, because automated scripts known as sweeper bots detect and confiscate incoming funds within milliseconds.
Understanding how these programmatic actors monitor transaction queues explains why manual rescue attempts fail and why specialized mechanisms like private transaction bundles provide the only viable recovery path.
The Anatomy of an Account Takeover
A cryptocurrency wallet does not contain assets directly; it holds a cryptographic private key that authorizes state changes on a distributed ledger. When a private key is exposed through phishing, malicious smart contracts, or compromised operational environments, an attacker obtains equal signing authority alongside the legitimate owner. For instance, security researchers documented an incident where key leaks led to rapid programmatic draining across dozens of accounts in the Bloom trading bot key compromise.
Attackers typically run automated scripts that transfer liquid native balances immediately. However, accounts frequently contain value that cannot be settled in a single instant transaction. These illiquid positions include tokens locked in staking contracts, unvested tokens released via periodic vesting schedules, governance escrow stakes, and assets requiring a time-delayed unbonding period.
To move these trapped secondary tokens, a transaction must execute on-chain. On networks like Ethereum and Solana, transactions require transaction fees—commonly known as gas—paid exclusively in the network's base asset. Because the drained wallet holds a zero balance of native tokens, it cannot broadcast a transfer to move the trapped collateral. This dynamic creates the trap: to save the tokens, the victim must send gas money to the compromised address, but doing so alerts the attacker's automated infrastructure.
How Sweeper Bots Monitor the Mempool
A sweeper bot is an automated program programmed to listen for balance changes on compromised addresses and broadcast immediate, high-priority transactions to siphon any newly arrived native value.
On Ethereum and similar EVM (Ethereum Virtual Machine) architectures, pending transactions circulate through an open, peer-to-peer gossip network called the mempool (memory pool) before miners or validators package them into blocks. Sweeper bots maintain persistent WebSocket connections to full nodes, constantly monitoring the public mempool for pending inbound transfers targeting their flagged addresses.
When a victim broadcasts a funding transaction from an exchange or a secondary wallet, the sweeper bot spots the pending transfer while it is still waiting for confirmation. The bot calculates the incoming amount, constructs an outbound transfer transaction signed with the victim's compromised private key, and submits it to the network.
To ensure its draining transaction executes before the victim can execute a recovery transfer, the bot leverages programmatic fee escalation. Under Ethereum's fee model governed by EIP-1559, transactions specify a maximum base fee and an optional priority fee (tip) paid directly to the validator. Sweeper bots deploy aggressive priority fees, incentivizing block builders to place the theft transaction immediately following the funding transaction in the same block. If the victim attempts to broadcast their own extraction transaction simultaneously, the sweeper bot's transaction simply outbids it, sweeping the gas before the legitimate contract interaction can execute.
On networks with different transaction ordering designs like Solana, which does not use a traditional public mempool, sweeper bots monitor incoming block confirmations and submit transactions across multiple remote procedure call (RPC) nodes with high priority fees, exhausting the account balance fractions of a second after funding.
The Mathematical Reality of Manual Recovery
Manual rescue attempts fail because human interaction cannot compete with automated programmatic execution. Consider a concrete numeric example on Ethereum.
Suppose an address holds $10,000 worth of unbonded governance tokens. To call the transfer() function on an ERC-20 smart contract, the transaction requires roughly 65,000 gas units. Assuming a prevailing base fee of 30 gwei and a standard priority fee of 2 gwei, the total gas price is 32 gwei per gas unit.
The cost to execute the transfer is calculated as:
65,000 gas × 32 gwei = 2,080,000 gwei = 0.00208 ETH.
The victim sends 0.005 ETH from a clean account to cover this fee, planning to immediately trigger the token transfer. However, the sweeper bot has automated the entire response pipeline. A simple native transfer from an externally owned account consumes a fixed 21,000 gas units.
The sweeper bot constructs a transaction using the compromised key that transfers the entire balance minus the execution cost. It sets a priority fee of 15 gwei—well above the standard market rate:
Gas cost for sweeper = 21,000 gas × 45 gwei = 945,000 gwei = 0.000945 ETH.
Amount swept = 0.005 ETH - 0.000945 ETH = 0.004055 ETH.
Because the sweeper bot offers a significantly higher tip to the block builder, the builder includes the sweeper's transfer first. The native $ETH arrives and departs within the exact same block or adjacent block. When the victim's manual ERC-20 transfer reaches the validator, the account balance is back to zero, causing the transaction to fail due to insufficient funds.
Rescuing Trapped Assets via Private Bundles
To rescue non-native assets from an address stalked by a sweeper bot, the victim must bypass the public mempool entirely and prevent the account from ever holding an unspent native gas balance.
This recovery model relies on private mempools and atomic transaction bundles, popularized by research frameworks such as Flashbots. Users interested in general transaction privacy and frontrunning protection can review the mechanics in our guide to MEV protection and private RPCs.
An atomic bundle is an ordered list of one or more transactions that is sent directly to specialized block builders via a private endpoint, rather than broadcast to the public peer-to-peer network. Crucially, block builders evaluate bundles on an all-or-nothing basis: either every transaction in the bundle executes in the exact sequence specified without any outside transactions placed between them, or the entire bundle is discarded.
A rescue bundle typically consists of two distinct transactions executed simultaneously in a single block:
- An external sponsor transaction: A separate, secure wallet initiates a transaction that calls a custom smart contract or executes a specific interaction that supplies execution fees directly, or the sponsor pays the block builder directly via an internal smart contract transfer (such as
block.coinbase.transfer()). - The asset extraction transaction: A transaction signed by the compromised private key that transfers the stuck tokens or NFTs to a secure destination address. This transaction is configured with a gas price of zero, relying entirely on the sponsor transaction or a direct builder payment to compensate the validator for inclusion.
Because this bundle is transmitted directly to block builders through a private communication channel, the sweeper bot never sees the transaction pending in the public mempool. Furthermore, because no native ether is left sitting in the compromised wallet between transactions, there is no intermediate balance for a sweeper script to seize. If builder competition or network reordering prevents the bundle from executing first, the bundle drops without settling, meaning the victim loses only minimal builder fees rather than their capital.
Similar rescue mechanics exist on other platforms through dedicated smart contract proxies and account abstraction architectures, which separate the authorization signer from the fee payer.
Common Misconceptions
Misconception: A sweeper bot is operated manually by an individual hacker. Sweeper bots are entirely autonomous software programs deployed on cloud infrastructure with persistent RPC connections. They do not wait for human approval to trigger thefts, executing within milliseconds of an event trigger.
Misconception: Speeding up your transaction gas fee allows you to beat the bot. Manual transactions sent via standard wallet interfaces cannot outpace automated mempool listeners. Even if a user sets an exceptionally high priority fee, a sweeper bot's algorithms will detect the inbound transfer in the mempool and programmatically submit a replacement transaction with an even higher fee before the block is mined.
Misconception: Staked tokens on a compromised key are permanently lost. While liquid tokens are lost instantly, staked assets requiring a cooldown or unbonding period can often be recovered. If the victim coordinates a private atomic bundle that triggers the withdrawal claim and the token transfer in the exact block that the unbonding period matures, the assets can be moved to safety before the sweeper can act.
Misconception: Changing the password on a web3 wallet stops the sweeper. Wallet passwords and PINs merely encrypt the private key file stored on a local device. If a seed phrase or private key has been exposed, resetting local software passwords has zero impact on the blockchain ledger, where the key remains permanently valid.
How This Connects to the Market
The existence and sophistication of sweeper bots highlight the structural risks inherent in transparent, latency-sensitive distributed networks. The proliferation of automated mempool exploits has driven a significant portion of on-chain activity away from public gossip networks and toward private order flow auctions.
This shift has broader implications for network design. Protocols are increasingly exploring account abstraction standards, such as ERC-4337 on Ethereum, which natively permit alternative fee-payment models where a third party (known as a paymaster) can sponsor transaction fees. By decoupling the signing key from the asset used to pay for execution, modern account architectures reduce the risk surface that allows sweeper bots to trap illiquid positions on compromised addresses.
Questions this story raises
- What is a sweeper bot in crypto?
- A sweeper bot is an automated software script that monitors a compromised blockchain address. Whenever native tokens (like ETH or SOL) are sent to the address to cover transaction fees, the bot instantly broadcasts a transaction to drain those funds before the owner can use them.
- Can I recover tokens if my private key is compromised?
- Yes, but only if the remaining tokens are illiquid (such as staked assets or NFTs) and you use private transaction bundles. Attempting to fund the wallet normally through the public mempool will result in the sweeper bot stealing your gas money.
- How does a private transaction bundle prevent sweeping?
- A private bundle sends your transactions directly to a block builder rather than broadcasting them to the public mempool. This hides the transaction from sweeper bots and allows a secondary account to pay the transaction fees atomically within the exact same block.
- Does changing my wallet password stop a sweeper bot?
- No. Wallet passwords only protect the local software application on your computer or phone. Once a private key or secret recovery phrase is exposed, the key is permanently compromised on the public blockchain, regardless of local application settings.
References
- [1] Flashbots Documentation: Technical Overview of Searcher Bundles — Flashbots
- [2] Ethereum Gas and Fees Specification — Ethereum Foundation
- [3] EIP-1559: Fee market change for ETH 1.0 chain — Ethereum Improvements Proposals
- [4] ERC-4337: Account Abstraction Using Alt Mempool — Ethereum Improvements Proposals
Evergreen explainer written by Basis Desk's system and checked by an independent model pass for factual errors and advice language. Figures, fees and rules change — the references above are where to verify current specifics. Market figures marked "at the time of writing" come from live exchange data. Report an error: corrections@basisdesk.news · corrections policy.
The Daily Brief, in your inbox at 07:00 ET
Five stories, the numbers that moved, what to watch. Three minutes. No hype, no advice, unsubscribe in one click.
Get the big crypto stories first
A few alerts a day at most: major breaking news and the morning brief. Switch off anytime.
Not financial advice. Basis Desk publishes information, not recommendations. Crypto assets are volatile and you can lose what you invest.