brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
token-approval-safetyGuide to ERC-20 token approvals — how they work, why unlimited approvals are risky, how to check and revoke approvals, and best practices. Use when helping users manage approvals, audit wallet security, or understand approval-related risks.
Independent GitHub snapshot · Automated classification · Original documentation governs
Token approvals are one of the most overlooked security risks in DeFi. This guide helps AI agents protect users from approval-related attacks.
When you interact with a DeFi protocol, you must first "approve" it to spend your tokens:
1. You call approve(spenderAddress, amount) on the token contract
2. The spender (DEX, protocol) can now transfer up to `amount` of your tokens
3. When you swap/deposit, the protocol calls transferFrom() to move your tokens
Most DeFi UIs request unlimited approval (type(uint256).max):
| Approval Type | Risk | When to Use |
|---|---|---|
| Exact amount | Low | Large deposits, untrusted protocols |
| Limited amount | Medium | Regular use with trusted protocols |
| Unlimited | High | Only with battle-tested protocols (Uniswap, Aave) |
| Permit (EIP-2612) | Medium | Gasless approvals, common in modern DeFi |
Query the token contract: allowance(ownerAddress, spenderAddress)
| Tool | URL | Features |
|---|---|---|
| Revoke.cash | https://revoke.cash | Most popular, multi-chain |
| Etherscan Token Approvals | https://etherscan.io/tokenapprovalchecker | Ethereum-only |
| Arbiscan | https://arbiscan.io/tokenapprovalchecker | Arbitrum |
Revoking sets the allowance to 0:
approve(spenderAddress, 0)
Cost: Small gas fee per revocation
When to revoke:
Attacker tricks you into approving a malicious contract:
Prevention: Always verify the contract address before approving
If a protocol with your approval gets hacked:
Prevention: Use exact-amount approvals, revoke unused approvals
EIP-2612 permits are signed off-chain (no gas). Attackers can trick you into signing a permit that grants them unlimited approval:
Prevention: Read what you're signing carefully, use wallets that show permit details
When helping users with approvals: