Jump to content
About Crypto

Crypto guides and market analysis

What Does Token Approval Let a dApp Do? ERC-20 Allowance

Approving a token in a wallet lets one named contract move that ERC-20 token up to your allowance through transferFrom, until you change or revoke it.

About Crypto Newsroom2 min read

What Does Token Approval Let a dApp Do? ERC-20 Allowance

One named contract can move up to a set amount of one ERC-20 token from your wallet, using the allowance you approve.

When you call approve(spender, amount), the token contract records an allowance for that spender. The spender is the contract address named in the approval. Later, it can call transferFrom to move tokens from your wallet, up to that allowance.

SyncSwap is a decentralized exchange protocol for trading tokens and using liquidity pools on supported networks. Its router makes it a concrete zksync defi example: when a swap executes, the router can pull the approved USDC amount from your wallet.

An ERC-20 allowance stays active until you change it

An allowance is stored on the token contract, so disconnecting a site in your wallet does not cancel it.

That means the spender can still use any remaining allowance later. The approval is tied to the spender address and token, not to your wallet’s current connection to a website. If you approved a router, that router address retains the allowance until you change it.

An unlimited approval is the maximum uint256 value. It avoids setting a new allowance for each swap, but it also gives that spender room to move your full balance of the token. If the spender is compromised or malicious, it can take the whole balance.

Set a finite amount or revoke the allowance

You can limit an ERC-20 approval to the amount you expect to spend, then approve zero to revoke the remaining allowance.

Say you want to swap 50 USDC. You can approve 50 USDC for the router, then let it use transferFrom when the swap executes. For a finite allowance, each transfer reduces the amount left to spend. If you approved more than the swap used, the remainder stays available.

To cancel that remainder, submit a new approval for the same token and spender with an amount of zero. That is a separate transaction. Revoke.cash can help you review and revoke token allowances, but the change still needs to be recorded on the token contract.

Before approving, check the spender address and amount in your wallet. Choose the exact amount when you want a defined limit, and revoke any allowance you no longer need.