Approval / Allowance
An ERC-20 approval sets an allowance that lets a specified address or smart contract spend up to a defined amount of a user's tokens.
✦ Key Insight
Approvals are necessary for many swaps and DeFi actions, but broad or forgotten allowances can create risk if the approved contract is malicious or later compromised. Users should understand what asset, spender, and amount they are authorizing.
✕ Common Misconceptions
An approval is not the same as a one-time transfer. Unlimited approvals may remain active after you finish using an app. Always verify the spender address and do not approve unexpected prompts.
Detailed Explanation
Aliases and acronyms: Token approval; ERC-20 approval; spending allowance; approve; allowance
Plain-English explanation: Many DeFi apps cannot move an ERC-20 token from your wallet until you authorize a spender. The approval transaction records how much that spender is allowed to transfer on your behalf. The remaining permission is called the allowance.
Analogy: It is like giving a company permission to debit your bank account up to an agreed limit without giving it ownership of the whole account.
How it works: The token holder calls the ERC-20 approve function for a spender and amount. The token contract stores that allowance. The spender can then use transferFrom within the approved limit, and the allowance is reduced or otherwise handled according to the token implementation.
FAQs
Q: Does an approval move my tokens immediately?
A: No. It grants spending permission. A later transferFrom or related call is needed to move tokens.
Q: What is an unlimited approval?
A: It is an allowance set to a very large value so repeated interactions do not require a new approval each time.
Q: Can I reduce an allowance?
A: Yes, if the token follows the expected approval interface. Wallets and approval-management tools can submit a new allowance, often zero, to remove permission.
Sources
In Practice
Dig Deeper
Smart Contract
A smart contract is self-executing code stored on a blockchain that automatically performs actions when certain conditions are met.
Token Approval
A token approval is an on-chain permission that a wallet owner grants to a smart contract, allowing that contract to transfer a specified (or unlimited) amount of a particular token (usually ERC-20) from the owner’s address.
Revoke
To revoke a token approval is to remove or reduce a previously granted spending allowance for a smart contract or address.
