Custody & Security in Practice
Approvals, Signatures & How Wallets Get Drained
You can lose every token in your wallet without your seed phrase ever being compromised, because approvals delegate spending authority to contracts, and most people grant them without reading what they authorize.
There are two distinct ways a wallet gets emptied. One is seed phrase compromise: someone gets your words, imports your wallet, and moves everything. The other is approval exploit: you sign a transaction that grants a contract permission to transfer your tokens on your behalf, and then that contract is malicious or gets exploited. Conflating these two leads to bad mental models about how attacks actually happen.
How ERC-20 approvals work
The ERC-20 standard includes an approve function. When you call it, you are telling a token contract: "address X is allowed to transfer up to Y of my tokens." Decentralized exchanges need this because the exchange contract must pull tokens from you to execute a swap. The approval is recorded in the token contract's state, not in your wallet. It persists until explicitly revoked, regardless of whether you disconnect the site, clear your browser, or even change wallets.
- You approve a contracton-chain allowance set; often unlimited
- Approval sits dormantyou forget about it; months pass
- Contract is exploitedattacker calls transferFrom with your allowance
- Tokens drainedyour seed is untouched; your tokens are gone
Unlimited vs exact approvals
Uniswap and most major DEX frontends default to requesting unlimited approval so you only pay the approval gas cost once. Exact approvals cost gas every transaction but cap the exposure to exactly what you are swapping now. Neither approach is obviously correct for everyone, but you should know which you are granting. Many users have approved unlimited USDC or WETH to contracts years ago and have no idea the allowance still exists.
Drainer mechanics
Modern wallet drainers typically use one of two flows. First, they convince you to sign a Permit message (no gas, looks like a simple "verify wallet" step), which encodes a token approval the attacker can submit. Second, they direct you to a contract interaction that calls approve with an unlimited amount to an attacker address. The frontend is disguised as a reputable project, often via a hacked or spoofed Twitter account or a Google ad.
- Verify the contract address of anything you interact with against the official documentation, not the URL alone.
- Read what your wallet prompts you to sign. "Set Approval For All" on an NFT contract grants permission over every NFT in the collection.
- Use Revoke.cash, Etherscan's Token Approvals tab, or the equivalent on other chains to audit and remove approvals you no longer need.
- Consider keeping high-value assets in a separate wallet that never interacts with DeFi.
>$100M
estimated losses to approval-based drainers and phishing in 2023 alone, per on-chain analytics firms
Key takeaways
Educational content only, not financial advice. Trading and investing carry real risk of loss, including your entire capital. Do your own research and consult a licensed professional before making financial decisions.
This is one lesson of 541.
The whole Foundation is free — 16 subjects, beginner to advanced. Sign in to track what you have read, take the end-of-module quizzes, and use the terminal.