Chapter 6 · Tokens · lesson 4
Why unlimited approval is a loaded gun
9 min
Builds on ERC-20 from scratch
Chapter 6 · Tokens · lesson 4
9 min
Builds on ERC-20 from scratch
Almost every dApp asks for an unlimited approval. Almost everyone grants one. Here is what you are actually agreeing to.
Approving exactly what you need means approving again on every purchase — an extra transaction and an extra fee, every time.
Approve type(uint256).max once and you never see the prompt again. From a
product perspective it is obviously better. That is why it won.
The cost is that you have granted a permanent, unlimited right to move that token out of your wallet, to a contract you may never think about again.
It survives you disconnecting. It survives you clearing browser data. It survives the project shutting down. It survives you forgetting the site existed.
If that contract is ever compromised — or was malicious from the start, waiting — everything you hold of that token goes, whenever the attacker chooses.
Predict
Approve what you need when the amount is known and the extra transaction is tolerable. Some wallets now let you edit the amount at the prompt.
Review and revoke periodically. Revoke.cash and Etherscan's approval checker both list every live approval on your address. Revoking is a transaction and costs gas, which is exactly why people put it off.
Use a burner for anything unfamiliar. A separate address holding only what that session needs cannot lose more than that.
Prefer permit where it exists (EIP-2612). A signed, time-limited,
amount-limited approval, submitted in the same transaction as the action — with
the caveat from track 2 that a permit signature is itself something attackers
will ask you to sign.
Check