If you’ve spent time in crypto, you came across token allowance. But do you really understand what it is? If not, don’t worry. In this post, we’ll explore what token allowance is and then show you how to set a custom token allowance with Zerion Wallet, revoke it, and more.
What is token allowance?
Before any Web3 app can use your tokens, you need to grant it your permission to spend them — this is commonly known as ‘token allowance’ or ‘token approval’.
These terms come from standard functions of any ERC-20 token smart contract. The ‘approve’ function lets you set the spending allowance for some dapp (like Zerion’s swap tab). The ‘allowance’ function returns how much some dapp can spend on your behalf.
In practice, you can just sign the transactions with your wallet. Understanding what happens under the hood is still useful — this can protect you from extra risks.
How does token allowance work?
Let’s take a look at an example of a simple interaction with a dapp: swapping tokens with Zerion.
After you connect your wallet, you get several transactions:
- Token approval — you approve Zerion’s smart contract to spend the token
- Token swap — you initiate the actual swap
- Second swap — you don’t need to give a new permission for this transaction because you already gave it in step 1
In Zerion Wallet's multichain transaction history, token approvals will show as 'others'. By clicking through, you can also see the gas fee you paid for the approval.
During high congestion on the mainnet Ethereum, gas costs of these extra transactions can add up quickly.
You also usually first see the (lower) gas cost of the first approval transaction. Only after granting the approval with your wallet, you get to see the total price of the swap. On the Ethereum network, the gas costs of the swap could be higher than what you wanted to swap… at least, that’s what happened during the bull run.
So to save on gas costs, most dapps request an unlimited allowance — but you can also customize your token allowance.
How to set a custom token allowance with Zerion
Most dapps, by default, request unlimited access to a token. This helps to save on gas on additional approvals for subsequent transactions. However...
A scam website can also trick you into granting an unlimited allowance — after that, the scammer will steal all of that token.
Finally, on Layer-2 networks, it usually doesn’t make sense to penny-pinch approval transactions. Gas is cheap anyway.
That’s why, in Zerion Wallet, you can customize your token allowance for any approval transaction.
Just set the token allowance to only the amount of tokens you want to spend in that specific transaction. Or you can set the allowance to what you feel is safe for that smart contract: higher for something battle-tested decentralized application like Aave and lower for any degen dapp.
Of course, you can also revoke any token approvals at any time.
How to check and revoke your token approval
There are several tools for checking your token approvals.
The easiest way to check and revoke token approvals is with Revoke.cash.
After connecting your wallet, you get a list of token allowances for various smart contracts across dozens of blockchains. You can then update or remove any token allowances.
Keep in mind that revoking each token approval costs some gas because it’s an onchain transaction. Unfortunately, there is currently no easy way to revoke all token approvals in one transaction.
That’s why it’s better always to customize token approvals and set a reasonable limit that doesn’t expose you to unlimited risk and still lets you save on gas.
Token permits: approval and spending in one transaction
As you’ve seen, approvals can be expensive, especially if you swap small amounts.
That’s why devs came up with a way to do both the approval and swap in one transaction.
Some token smart contracts have a newer function: permit.
The permit function lets you set the allowance and spend tokens in one transaction.
This saves gas on the first swap for that pair. You also get to see the total gas cost of the swap right away.
The only problem is that not all tokens and not all dapps support this function.
The best-known DEX that uses this feature is 1inch. They also have an up-to-date list of tokens with permits — it currently includes USDC, DAI, UNI tokens, and other popular tokens.
Conclusion
In this post, we explored what token approval and token allowance are, examined why you should set a custom allowance, and how to do this with Zerion Wallet. We then explained how to check and revoke your token approvals. Finally, we explored the newer function of token permits that can help to save on gas by combining approval and swap in one transaction.
Unlimited token approvals expose you to an unnecessary risk. It’s a good practice to set a custom token allowance, which you can easily do with Zerion Wallet.
FAQ
Why is token approval needed?
Token approval is a smart contract function that gives a dapp your permission to spend tokens on your behalf. It’s a required transaction that you need to sign before you can do an actual swap or any other transaction with the token.
What is the difference between token approval and allowance?
Both token approval and allowance are standard functions of an ERC-20 token smart contract.
Token approval grants the user permission to spend the token. For example, you can approve Uniswap's smart contract to access USDC. This is a required step before you can swap USDC to another token.
Meanwhile, token allowance returns how much can spent by a specific address — initially, it’s zero, and after a token approval, it’s whatever is set.
Is there a token allowance checker?
Yes, with Revoke.cash, you can check your allowance across many networks and revoke access.
You can also check allowance on the Ethereum network with Etherescan’s checker. There are similar features on many blockchain explorers on other networks.
What does revoking the token allowance mean?
Revoking the allowance means you set token approval to zero. After that, the smart contract can no longer spend tokens on your behalf.
Do NFTs have token approvals?
Yes, NFT smart contracts also have setApprovalForAll() function that lets a dapp spend all NFTs within that collection. For example, OpenSea can request that approval.
What are the allowances in ERC-20?
Upon the approval of the ERC-20 token, the allowance function shows the maximum possible withdrawal by the authorized address.
Why are token allowances risky?
Token allowances let smart contracts spend tokens on your behalf. Of course, normally, you still initiate any operation with these tokens. But if the smart contract is hacked, attackers may be able to steal all your tokens. With Zerion Wallet, you can always set custom token allowance.