Track 5 · Tokens · lesson 4

Why unlimited approval is a loaded gun

9 min


Almost every dApp asks for an unlimited approval. Almost everyone grants one. Here is what you are actually agreeing to.

Shopper.solComplete
Loading editor…
Approve exactly what is needed, not everything you will ever own.
Run the code to see what happens.
Nudge
The function already receives the number it should be approving.
Show me the approach
`type(uint256).max` is the largest number the EVM can hold. It is not what the caller asked for.
Show me the code
Pass `amount` instead of `type(uint256).max`.
Explain the solution
Unlimited approvals exist because they save a transaction on every later purchase. That convenience is why most wallets hold dozens of them — and why one compromised contract can empty a wallet that stopped using it years ago.

Why unlimited is the default

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

You granted an unlimited USDC approval to a DEX in 2022 and haven't used it since. Today the DEX is exploited. What happens to your USDC?

Choose one answer

What to actually do

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

What is the safest habit around approvals?

Choose one answer

Worth remembering

  • Unlimited approvals exist to save a transaction per purchase, and that convenience is why they dominate.
  • An approval is permanent, survives disconnecting, and does not expire.
  • A contract compromised years later can use every approval ever granted to it.
  • Approve what you need, revoke what you don't, and use a burner for anything unfamiliar.
  • `permit` gives signed, bounded approvals — but the signature itself is a phishing target.