NewsCryptoERC-20 Allowances Explained: How Token Approvals Work and How to Revoke Them

ERC-20 Allowances Explained: How Token Approvals Work and How to Revoke Them

Author: Cryptsy·

Key Takeaways

  • •An ERC-20 allowance is a value recorded in the token contract that specifies how much a designated spender may move from an owner's balance, and it is scoped to one token contract, one owner, one spender, and one network.
  • •The EIP-20 standard implements the mechanism through the approve, allowance, and transferFrom methods, which decentralized applications use for swaps, liquidity provision, staking, lending, and bridging.
  • •Unlimited approvals, often requested to spare users repeated transaction fees, remain active until revoked and continue to cover tokens deposited after the grant, so hardware wallets protect signing keys but not already-granted permissions.
  • •EIP-2612 permits let users set allowances by signing a message instead of paying for an approval transaction, though the deadline limits signature validity and does not expire the resulting allowance.
  • •Revoking requires a zero-value approval transaction for each token and network, blocks only future transfers, and does not recover tokens that have already been moved.
ERC-20 Allowances Explained: How Token Approvals Work and How to Revoke Them

An ERC20 allowance is the amount of a token that the owner has authorized another address, known as the spender, to move out of that balance. The EIP-20 token standard builds the mechanism from three methods: approve, allowance, and transferFrom. When a decentralized exchange, bridge, or vault asks a user to approve a token, it is asking the user to set one. TokenToolHub's guide to ERC-20 allowances notes that many wallet drains rely on permission the user has already granted, meaning the figure deserves more attention than a typical wallet pop-up gives it. The sections below cover how an allowance is defined and scoped, where it sits in the ERC-20 standard, how approve and transferFrom move tokens, why unlimited approvals are common, how signature-based permits differ, and how to check and revoke what has been granted.

What Is an ERC20 Allowance?

The allowance is a number stored in the token contract that records how many tokens one spender may still move from one owner's balance. A wallet app only displays it. TokenToolHub ties each allowance to one owner, one token contract, one spender, and one network.

According to TokenToolHub, approving a spender for Token A does not approve it for Token B, and an approval on Ethereum does not create the same allowance on BNB Smart Chain, Polygon, Arbitrum, or Base. Standard ERC-20 allowances also do not cover native ETH, although wrapped ETH (WETH) is itself a token and can be approved. NFT standards use separate approval systems.

The Token Owner

The owner is the address that holds the token balance and grants permission. TokenToolHub notes that this can be an ordinary wallet, a multisig, a smart account, or another contract.

The Spender

The spender is the address allowed to call transferFrom against the owner's balance. It is usually an exchange router, staking contract, bridge, lending market, or vault, though an ordinary wallet address can be a spender too.

The Approved Amount

The amount is the ceiling the spender can move under the active allowance. TokenToolHub's example shows how the token contract records it. The figure can match a single trade exactly or, as covered below, be set so high that it never runs out.

Where the Allowance Fits in the ERC-20 Token Standard

The allowance is one part of a shared interface for fungible tokens on Ethereum. According to ethereum.org's ERC-20 developer documentation, ERC-20 stands for Ethereum Request for Comments 20, and Fabian Vogelsteller proposed it in November 2015 as a token standard that implements an API for tokens within smart contracts. Fungible means each token is identical in type and value to every other token of the same kind.

The EIP-20 specification lists Fabian Vogelsteller and Vitalik Buterin as its authors, shows a created date of 19 November 2015, and carries Final status. Its abstract says the standard lets tokens be transferred and also approved so another on-chain third party can spend them.

ethereum.org lists four jobs the standard covers: transferring tokens between accounts, reading an account's token balance, reading the total supply, and approving an amount of tokens that a third-party account can spend. A smart contract that implements the required methods and events can be called an ERC-20 token contract, and once deployed it keeps track of the tokens it created.

Decimals and Raw Amounts

Allowances are stored as whole numbers, not as the figure a wallet shows. EIP-20 explains that a token reporting 8 decimals means the stored amount is divided by 100000000 to get the user-facing figure. The decimals method is optional, and EIP-20 says other contracts must not expect it to be present. Proof of Talk's article on token allowances advises recording raw integer values alongside verified decimals so a readable limit does not hide a scaling error.

How approve and transferFrom Move an ERC20 Token Through the Contract

The owner grants, the spender spends, and the token contract enforces the limit. EIP-20 defines each step:

  • Approve. The owner calls approve(_spender, _value). EIP-20 says this lets the spender withdraw from the owner's account multiple times, up to _value.
  • Record and log. The token contract stores the allowance and must emit an Approval event, carrying the owner, spender, and value, on every successful approve call.
  • Spend. The spender later calls transferFrom(_from, _to, _value). EIP-20 calls this a withdraw workflow that lets contracts transfer tokens on the owner's behalf and says it should throw unless the _from account deliberately authorized the caller. Each call must fire a Transfer event.
  • Check. Anyone can call the read-only allowance(_owner, _spender) method to see how much the spender is still allowed to withdraw.

Before a transferFrom goes through, TokenToolHub says the token contract checks that the owner has enough token balance, that the caller is the authorized spender, that the allowance covers the requested amount, and that any extra token rules are met. A limited allowance then shrinks as it is used, as shown in TokenToolHub's example. The spender does not need the owner to sign again for each later transfer.

Cube Exchange's explainer on token approvals walks through a lending deposit: the user approves the lending contract, then calls its deposit function, and inside that function the contract calls transferFrom to pull in the tokens. Cube calls this pull-based settlement.

Approving Is Different from Connecting

Connecting a wallet shows an app the user's public address. It does not grant any spending power. An approval is an on-chain transaction that creates a standing permission, and TokenToolHub points out that it normally moves no tokens at the moment it is signed and that disconnecting the site later leaves the permission in place.

Why Ethereum Apps Ask for Approval Instead of a Token Transfer

A plain transfer sends tokens to a contract without telling it anything. Per ethereum.org, the ERC-20 standard has no mechanism to notify a receiving contract, so tokens sent to a contract that cannot handle them can be stuck for good. As of 20 June 2024, ethereum.org counted at least $83,656,418 worth of ERC-20 tokens lost this way.

The documentation says transfer is not designed for depositing tokens to contracts and points to the approve and transferFrom pattern instead. It also names alternative token standards, ERC-223 and ERC-1363, that grew out of this problem. Cube Exchange adds that the approval pattern lets an app coordinate the token movement with its own bookkeeping in one transaction, pulling the exact amount it needs while its logic runs.

TokenToolHub lists the common places users meet an approval request:

  • Exchange swaps: a router needs permission to move the token being sold.
  • Liquidity provision: each ERC-20 asset deposited normally needs its own approval.
  • Staking and vaults: the contract pulls the token into custody before issuing a position or vault shares.
  • Lending: deposits, repayments, and collateral move through allowances.
  • Bridges: a bridge may move tokens into a custody contract before assets appear on the destination network.
  • Payments and marketplaces: contracts collect one-time or repeated token payments, bids, or fees.

Changing an ERC20 Allowance: Overwrites and the Race Condition

A new approve call replaces the old value. It does not add to it, as TokenToolHub's example shows.

Overwriting creates a timing problem. Zealynx's allowance glossary entry describes how a spender watching the mempool can use the old allowance before the change confirms.

EIP-20 tells wallet interfaces to set the allowance to 0 before setting a new value for the same spender. It leaves this to clients on purpose, because forcing it in the contract would break backwards compatibility with tokens deployed earlier. Zeroing first takes two transactions, and TokenToolHub notes that some tokens reject a direct change from one nonzero allowance to another, so the two-step route is required there anyway. Some libraries add increaseAllowance and decreaseAllowance helpers that adjust the value relative to its current level. Cube Exchange notes these helpers are not part of the original standard.

Unlimited Token Approvals and Why Apps Request Them

Many apps ask for the largest possible value, type(uint256).max, so the user approves once and skips paying for another approval on that token. TokenToolHub notes that many implementations treat this value as infinite and do not reduce it when the spender uses it.

Proof of Talk adds that OpenZeppelin's ERC20 implementation documents this infinite treatment, and that its transferFrom does not emit a fresh Approval event when it reduces an allowance. Accounting built only on event logs can therefore be incomplete. The live value should be read with allowance instead.

The risk lasts as long as the permission does:

  • Future balances are exposed. TokenToolHub notes that an unlimited approval covers tokens that arrive after it was granted, not just what the owner held at the time.
  • An empty wallet is not safe. Proof of Talk points out that a zero token balance leaves nothing to move today, but the permission still matters once a later deposit lands.
  • Spenders can change. A contract that was safe when approved can be compromised or upgraded later, and the old approval still points at the same address.
  • Keys stay safe while tokens leave. A spender with a valid allowance does not need the owner's seed phrase. TokenToolHub notes that a hardware wallet protects signing keys but does not cancel approvals already granted.

Cube Exchange notes that many costly wallet drains start with a valid approval rather than a stolen private key.

Permits: An ERC-20 Token Approval Created by Signature

ERC-2612 (often written EIP-2612) adds a permit function. Instead of sending an approve transaction, the user signs a typed message naming the owner, spender, value, a nonce, and a deadline. Anyone can submit that signature on-chain, and the token then sets the allowance.

According to Cube Exchange, two safeguards make this work: a domain separator that binds the signature to one contract and chain, and a nonce that lets each signed permit be used only once. Zealynx adds that the user skips paying gas for a separate approval transaction.

A permit is still a spending permission. Cube Exchange notes that a relayer can hold a valid permit back, and another party can submit it first. Proof of Talk explains that the deadline limits when the signature can be accepted; it is not an expiry date for the allowance it creates. TokenToolHub warns that a permit request can feel like a harmless message signature while granting spending power, so the spender, token, amount, deadline, and chain should be checked before signing.

How to Check and Revoke an ERC20 Allowance

To revoke, the owner calls approve again for the same spender with a value of zero. TokenToolHub says a revocation commonly shows up as an Approval event with a zero value, and its guide sets out the limits:

  • It is an on-chain transaction, so the owner signs it and pays a network fee.
  • The old allowance stays live until the revocation confirms, and a spender can use it first.
  • It covers one token on one network. It must be repeated for every token and chain where that spender was approved.
  • It stops future use only. Tokens already moved do not come back.

A practical routine looks like this:

  1. List each token, spender, and approved amount for the address on every network in use.
  2. Deal first with unlimited, unfamiliar, and old approvals, and those covering large balances.
  3. Send the zero-value approval, wait for confirmation, then read the live allowance again.
  4. Next time, approve only the amount a single action needs, accepting that additional approval transactions will cost more in fees.

TokenToolHub also suggests keeping long-term holdings in a separate wallet from the one used with apps. Any approval granted from a self-custody wallet stays in force until it is changed on-chain. Because unlimited approvals keep covering tokens that arrive after they are granted and a spender contract can be compromised or upgraded after approval, the routine above is one to repeat as an address's app usage changes rather than a one-time cleanup.

Nonstandard ERC-20 Token Behavior That Affects Approvals

Not every token follows the reference design. EIP-20 itself says callers must handle a false return and must not assume one never comes back. TokenToolHub lists the main variations:

  • Older or nonstandard tokens may not return the expected success value from approve or transfer.
  • Fee-on-transfer tokens deliver less than the requested amount, while the allowance may be reduced by the gross amount.
  • Some tokens block approvals for blocklisted wallets or paused accounts.
  • Upgradeable tokens can change their approval and transfer behavior after an upgrade.

Cube Exchange notes that wrapper libraries such as SafeERC20 are widely used because of these differences, so apps do not misread a failed approve or transferFrom.

Frequently Asked Questions

What Is an ERC20 Allowance?

It is the amount of a token that an owner has authorized a spender address to move through the token contract with transferFrom. The owner sets it with approve, and anyone can read it with the allowance function.

Is ERC-20 the Same as Ethereum?

No. Ethereum is the network, and ERC-20 is a token standard for smart contracts running on it. Standard ERC-20 allowances do not apply to native ETH, though wrapped ETH is an ERC-20 token and can be approved.

What Is ERC-20 Used For?

ERC-20 gives fungible tokens a shared interface so wallets and decentralized exchanges can work with any of them. According to ethereum.org, such tokens can represent reputation points, in-game skills, company shares, fiat currency such as USD, or an ounce of gold.

Does an Approval Move Tokens Straight Away?

Normally no. An approval records a permission in the token contract. Tokens only move later, when the spender calls transferFrom within the approved amount.

Does One Approval Cover Every Token in a Wallet?

No. A standard approval applies to one token contract, one owner, one spender, and one network. Each other token needs its own approval.

Does Disconnecting a Wallet from an App Revoke an Allowance?

No. Disconnecting ends the app's session with the wallet. The allowance lives in the token contract and stays active until it is spent, changed, or revoked on-chain.

Does Revoking an Allowance Recover Stolen Tokens?

No. Revoking sets the allowance to zero and blocks future transfers by that spender. Transfers that already went through are not reversed.

Why Do Apps Ask for Unlimited Approval?

It saves the user from sending a new approval transaction before each swap or deposit. The trade-off is that the spender keeps access to the current and future balance of that token until the allowance is revoked.

Source: Cryptsy