DEV Community

Gideon Elliott
Gideon Elliott

Posted on

How to Check Token Approvals Before a Wallet Swap

Check the spender and allowance before you sign. A token approval lets a smart contract move a set amount of that token from your wallet; it does not make the swap itself or give the contract access to every token you hold.

What does an approval let a contract do?

An approval sets an allowance: the amount a specific address may transfer from your wallet. Under the ERC-20 standard, the spender can use that allowance through transferFrom, often to take the input token when a swap executes.

  1. Identify the spender. Read the contract address shown in your wallet and check that it matches the spender shown by the swap interface. A token name or familiar logo is not enough to verify an address.
  2. Read the allowance amount. A limited approval caps how many tokens that spender can take under the permission. An unlimited allowance may be displayed as “unlimited” or a very large number, and can remain usable after this swap.

Why might approval be a separate step?

Your wallet must authorize token use before a contract can transfer the input asset. A centralized exchange can debit tokens held in your exchange account; with cowswap, your tokens remain in your wallet, and the approval gives a specific spender permission to use them. Signing an order and approving a token are different actions.

  1. Check whether approval is already in place. If the allowance covers the amount you plan to swap, the interface may not ask for another approval. A new token or spender, or an insufficient allowance, can require one.
  2. Distinguish a transaction from a signature. A standard approval is an on-chain transaction, so it uses network gas and must confirm before the swap can proceed. Some tokens support a permit signature instead; that authorizes an allowance through a signed message. Check what your wallet is asking you to sign.

How should you approve the amount you need?

For an occasional swap, I prefer a limited allowance close to the amount I intend to spend. For frequent trading, an unlimited allowance can save repeat approval transactions, but it leaves more spending power with that spender if its contract or security is compromised.

  1. Enter the swap amount first. That gives you a concrete figure to compare with the approval request; for example, if you plan to swap 100 USDC, check whether the requested allowance is near 100 USDC or vastly larger.
  2. Review the approval in your wallet. Confirm the token, network, spender address, and amount. If the wallet shows an unlimited amount when you expected a limited one, stop and check the interface’s approval settings before signing.
  3. Confirm the approval, then review the swap separately. The approval grants spending permission; it does not guarantee a particular exchange rate or complete the trade. Once it confirms, inspect the swap details and sign that action only if they still match your intent.

What should you do with an old allowance?

Revoke an allowance when you no longer want a spender to use it, especially if you do not recognize the contract or no longer trust the service. Disconnecting your wallet from a website does not revoke an on-chain allowance, and revoking typically requires a separate transaction and network gas.

  1. Check allowances on the same network. Use your wallet or a reputable block explorer’s token approval checker to find the token, spender, and remaining amount. On cowswap, as on other swap interfaces, the allowance belongs to the token contract and spender on that network.
  2. Set the allowance to zero if you want to remove it. Review the revocation transaction, submit it, and check that it confirms. Ethereum.org’s revocation instructions explain the process; you will need to approve again before that spender can use the token in a future swap.

Top comments (0)