When transferring your full ETH balance from one wallet to another, most wallets leave a tiny amount of "dust" behind. This happens because they slightly overestimate gas fees to prevent transaction failure under volatile conditions.
But sometimes, you want zero balance left — no dust, no leftovers — for example, when migrating to a new wallet, shutting down an address, or sweeping all funds.
Here's how you can do it perfectly, using only MetaMask and Chrome console.
🛠 Step-by-Step Instructions
- Open your Chrome browser.
- Unlock your MetaMask extension.
- Transfer all valuable tokens, NFTs, and other assets
- Open DevTools → Console tab (
F12
orCtrl+Shift+I
). - Paste and REPLACE the RECEIVER address as you intended
- Execute the following script:
(async () => { const sender = (await ethereum.request({ method: 'eth_requestAccounts' }))[0]; const receiver = '0xReceiverAddress'; // 🔥 Change this to your destination address const balanceHex = await ethereum.request({ method: 'eth_getBalance', params: [sender, 'latest'], }); const gasPriceHex = await ethereum.request({ method: 'eth_gasPrice', }); const gasLimit = 21000; // Standard gas for basic ETH transfer const gasFee = BigInt(gasPriceHex) * BigInt(gasLimit); const balance = BigInt(balanceHex); const amountToSend = balance - gasFee; if (amountToSend <= 0n) { throw new Error('Not enough balance to cover gas fee.'); } const txHash = await ethereum.request({ method: 'eth_sendTransaction', params: [{ from: sender, to: receiver, value: '0x' + amountToSend.toString(16), gas: '0x' + gasLimit.toString(16), gasPrice: gasPriceHex, }], }); console.log('Transaction sent! TxHash:', txHash); })();
Confirm the transaction in MetaMask popup.
✅ Done! Your account will now be completely emptied.
🧠 Why Not Just Use Wallet UI?
Wallet UIs like MetaMask intentionally overestimate gas fees to reduce transaction failure risks.
This means:
- They cannot send the full balance.
- They must leave a small "dust" amount as a safety margin.
By manually calculating gas cost and subtracting it ourselves, we can send the maximum possible safely.
📝 Why I Care About This
When EIP-1559 was introduced, dynamic fees made gas price calculations trickier, and wallets became even more conservative.
I often found myself frustrated by the "dust problem" when I simply wanted to sweep a wallet clean. This method helped me move entire balances safely and efficiently, many times over.
Feel free to bookmark this guide for the next time you need a clean sweep. 🧹✨
Top comments (0)