Sub topic 14
Limiting Losses and Responding to a Bad Interaction
Assume you already understand wallets, token addresses, transactions, decentralized exchanges, and basic block explorer pages. This chapter focuses on what to do after you notice a suspicious claim, approval, signature, or token purchase.
A bad interaction does not always mean your private key was exposed. The damage depends on what you authorized:
- A token approval lets a spender move that token from your wallet.
- A permit or similar signature can create an approval without an on-chain approval transaction.
- A transaction can send assets immediately or change contract permissions.
- A leaked seed phrase or private key gives full control of the wallet.
Disconnecting a website from your wallet only stops that website from requesting new actions. It does not revoke approvals that already exist.
First response: stop and classify
Do not submit another transaction to “fix” the first one. Close the site and avoid links sent through direct messages. Record the wallet address, contract address, transaction hash, domain, and time. This evidence helps you investigate and report the incident.
Check the transaction on a block explorer. Look for token transfers, approval events, permit-related actions, and unexpected contract calls. Separate the response into two cases:
- If you granted an approval but still control the wallet, revoke the approval.
- If the seed phrase or private key may be exposed, stop using that wallet and move remaining assets to a new wallet using a trusted device.
If assets are actively leaving the wallet, speed matters. Do not wait for a suspicious token to become valuable. Move native currency first if it is needed to pay for the transfer, but verify every address before signing.
Revoke token approvals
An approval normally names a spender and an allowance. Revoke the allowance by setting it to zero. Use a reputable wallet feature or a well-known approval-management tool, and verify that the network and token address are correct.
The following ethers v6 script revokes one ERC-20 allowance. It sends a real transaction, so inspect the values before signing.
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
const abi = [
"function approve(address spender, uint256 amount) returns (bool)"
];
const token = new ethers.Contract(
process.env.TOKEN_ADDRESS,
abi,
wallet
);
const spender = process.env.SPENDER_ADDRESS;
const tx = await token.approve(spender, 0n);
await tx.wait();
console.log("revoked in transaction:", tx.hash);This works for a standard ERC-20 approval. It may not remove permissions created by a different approval system, such as Permit2. Check those systems separately. Also remember that revoking an allowance does not undo a transfer that already happened.
When the key may be compromised
If anyone may know the seed phrase or private key, treat the wallet as permanently unsafe. Create a new wallet with a new seed phrase. Confirm the new address through a trusted wallet interface, then transfer remaining assets. Never enter the old seed phrase into a “recovery” website.
If a drainer is running, an attacker may race your transfer. Do not repeatedly sign random transactions or trust people offering recovery services for an upfront payment. Preserve transaction hashes and report the addresses to the relevant exchange, chain explorer, wallet provider, and law-enforcement or fraud-reporting service available in your region.
A response flow
Exercise
Exercise
You connected to a claim site and signed an unlimited token approval. No tokens have moved, and your seed phrase was never entered. What should you do first?
Show answer
Stop using the site, identify the exact token and spender, revoke that approval by setting its allowance to zero, and review the wallet for other suspicious permissions.