Foundations · Wallets & Security
Token Approvals
A token approval gives a smart contract standing permission to spend a specific token from a wallet, often an unlimited amount, and it stays in force until it is revoked.
Why it matters
Using a decentralized exchange, a lending app or an NFT marketplace nearly always begins with a request to “approve” a token. It looks like a formality before the real action, and most people click through it.
An approval is a permission that outlives the action it was given for. Forgotten approvals to contracts that later turn out to be malicious or flawed are a recurring way tokens are taken from wallets whose keys were never exposed.
How it works
- You approveYou let a contract spend a token from your wallet.
- Allowance is storedOften unlimited, and it stays until revoked.
- Contract can spendUp to the allowance, without asking again.
A token on a network such as Ethereum is a smart contract that keeps a table of balances. For another contract to move tokens out of a wallet, for example to carry out a swap, the token contract needs to know that the wallet’s owner allows it.
The owner grants that by signing an approval. It records three things: the spender, which is the contract being trusted, the token, and the allowance, which is the highest amount the spender may take. From then on the spender can pull tokens up to the allowance in one or many steps, without any further signature.
That is why a first swap of a token usually takes two prompts: an approval, then the swap itself. The network’s own coin, such as ether on Ethereum, is sent directly with a transaction and needs no approval.
In plain words
An approval is like a standing order at a bank that lets a company collect money from an account. A fixed limit caps what can be collected. An unlimited one lets the company take whatever is there, on any day, until the order is cancelled.
Connect, approve, transfer
The three actions sit close together on screen and mean different things. The distinction that matters most is between connecting and approving. Disconnecting a wallet from a website removes the site’s ability to send requests. It does not touch an approval, which is stored in the token contract on the blockchain.
Exact and unlimited
| Aspect | Exact amount | Unlimited |
|---|---|---|
| What the contract may take | Only the amount for this action | Any amount of that token, now or later |
| Next time the app is used | A new approval and a new fee | No further approval needed |
| If the contract is malicious or hacked | Nothing is left to take once the allowance is used | The whole balance of that token is exposed |
| Tokens added to the wallet later | Not covered | Covered |
Many applications request an unlimited allowance by default, so that the user pays the approval fee once and never sees the prompt again. Many wallets let the user edit the amount before signing.
An approval is specific. It covers one token, one spender and one network. An allowance for token A says nothing about token B, and an approval on one network does not exist on another.
Going deeper
Revoking. An allowance is removed by setting it back to zero. That is a transaction in its own right: it must be signed and costs a network fee. Block explorers and some wallets can list the approvals an address has granted and offer a revoke action for each.
NFT approvals. Collections use a broader permission, commonly shown as “set approval for all”. It lets the spender move every item of that collection held by the wallet, including items acquired later.
Approvals by signature. Some tokens accept a permit: a signed off-chain message that creates an approval without a transaction or a fee. The effect is the same, and the prompt looks like a harmless message. See signing transactions.
Honest contracts fail too. An approval is a bet on the spender’s code as well as its intentions. If a well-known application’s contract has a flaw, attackers may be able to use the allowances it holds. This is one form of smart contract risk.
Approvals stay with the address. Moving tokens to a new wallet takes them out of reach of old approvals. Sending the same token back to the old address puts it within reach again.
A hypothetical forgotten approvalHypothetical illustration
Noor holds 50 units of a token and wants to swap them. The exchange app asks for an approval, and the wallet shows an unlimited allowance for the app’s contract. She approves, swaps the 50 units and forgets about it.
Eight months later the same wallet holds 2,000 units of that token. A flaw is found in the contract she approved, and an attacker uses it to pull tokens from every wallet with an open allowance. All 2,000 units leave Noor’s wallet in one transaction that she never signed.
With an approval for exactly 50 units, the allowance would have been used up by the first swap and nothing would have been left to exploit. Revoking the unlimited approval at any point in those eight months would have had the same effect.
What it does NOT mean
- An approval is not a payment. No tokens move when it is signed. Permission is granted for them to be moved.
- An approval does not expire by default. It lasts until it is revoked or used up, however long ago it was given.
- Disconnecting a site does not revoke anything. Connection and approval are separate.
- An approval does not expose the whole wallet. It covers one token for one spender. Many approvals together can cover a great deal.
- A well-known application is not a guarantee. Reputable contracts have been exploited, and fake sites imitate reputable names.
Common mistakes
- Clicking through the approval prompt. It is the step with lasting consequences, and it is shown before the step people care about.
- Accepting unlimited by default. The amount is often editable, and few people look.
- Never reviewing old approvals. Permissions granted years ago to abandoned projects still work.
- Approving on a site reached through a link. A look-alike site can request an approval for the attacker’s own address. See fake airdrops and wallet drainers.
- Assuming a hardware wallet blocks it. The device signs the approval its owner confirms.
Risks and limitations
- Revoking costs a fee each time, and it cannot recover tokens that have already been taken.
- Tools that list approvals may not cover every network or every type of permission, including some signature-based ones.
- Exact approvals reduce exposure and add prompts and fees. Some applications do not work smoothly with them.
- Details vary between token standards and chains. Not every network uses this approval model.
Key takeaway
A token approval is standing permission for a contract to spend a token, often without limit and with no expiry. It stays in force after the website is closed, until it is used up or revoked.
Sources and further reading
- Mastering Ethereum, Andreas M. Antonopoulos and Gavin Wood (2018). Chapter on tokens: the ERC-20 standard and its approve, allowance and transferFrom functions
- ERC-20: Token Standard (opens in a new tab), Ethereum Improvement Proposals. approve lets a spender withdraw up to a set amount, multiple times; allowance returns the amount the spender may still withdraw
- Ethereum security and scam prevention (opens in a new tab), ethereum.org. When interacting with smart contracts, do not allow unlimited spend limits