DeFi Intel

Set Custom Token Allowances in MetaMask: Step-by-Step

Every time you connect your wallet to a decentralized app (dApp) and approve a token, you’re granting permission for that smart contract to spend a certain amount of your tokens. By default, many dApps request an unlimited allowance—effectively giving them the keys to your entire balance of that token, forever. While convenient, this practice introduces a major security vulnerability: if the dApp’s contract is compromised or malicious, an attacker can drain every token you hold.

In this guide, you’ll learn how to set custom token allowances in MetaMask, specifying only the exact amount needed for your transaction. We’ll walk through the manual process step by step, cover how to verify and revoke existing allowances, and explain the underlying mechanics of ERC-20 approvals. By the end, you’ll be able to interact confidently with any dApp while keeping your assets safe from over‑permission risks.

Key takeaways
  • Default unlimited token approvals are a major security risk; they never expire and can be drained if the dApp contract is compromised.
  • Setting a custom allowance limits the dApp to exactly the amount you authorize, protecting the rest of your balance.
  • In MetaMask, you can edit the approval amount by clicking the 'Edit' button next to the allowance during the approval prompt.
  • Use tools like Revoke.cash or Etherscan to verify and revoke existing allowances, especially for dApps you no longer use.
  • Always double‑check the spender address and understand the token’s decimal precision when entering custom amounts.
  • Consider revoking old allowances regularly and using a hardware wallet for additional security.

Why Default Unlimited Approvals Are Dangerous

When you approve a token for a dApp, you’re executing an approve() function on the token’s smart contract. This sets an allowance—the maximum amount the dApp’s contract can spend on your behalf. Most dApps request the maximum possible value (2^256 - 1) to avoid repeated approval prompts for small transactions. However, this creates a persistent risk: the allowance remains until you explicitly revoke it, and if the dApp’s contract ever gets exploited, the attacker inherits that spending power.

High‑profile hacks have drained millions because users left unlimited approvals active on compromised protocols. By setting a custom allowance—for example, exactly 100 USDC for a single trade—you limit the potential damage to that precise amount. Even if the contract is later compromised, the attacker can only take what you allowed, not your entire balance.

⚠️ Important: An unlimited allowance never expires. It stays valid until you manually revoke it, making you vulnerable long after you’ve stopped using the dApp.

Understanding ERC-20 Allowances

The ERC-20 token standard defines a two‑step approval process: first you call approve(spender, amount) to set the allowance, then the dApp’s contract calls transferFrom(yourAddress, recipient, amount) to move tokens. The allowance is stored on the token contract, not in MetaMask. You can check it at any time via Etherscan or any block explorer.

Allowances are specific to a token–spender pair. Approving 100 DAI for Uniswap V2 doesn’t affect any other DAI allowances you might have for other dApps. When you set a custom allowance, you’re simply lowering the approval to the exact amount needed—often the number of tokens you want to trade plus a small buffer for network fees (if applicable, though gas is paid in ETH, not the token).

In MetaMask, when you click “Approve,” the wallet displays a confirmation screen showing the requested allowance. If the dApp asks for an unlimited amount, MetaMask shows a warning: “This can leave your balance at risk.” By manually editing the allowance field, you override the dApp’s request with your custom value.

Prerequisites for Setting a Custom Allowance

If you see an approval prompt but cannot edit the amount in MetaMask, try using the “Use custom” toggle (if present) or switch to the advanced interface. As of late 2023, MetaMask’s default approval screen allows you to set a custom value by clicking the “Edit” button next to the amount.

Step-by-Step: Setting a Custom Allowance in MetaMask

  1. Initiate an action on a dApp – For example, go to a DEX and click “Swap” with a token pair. The dApp will ask you to approve the token first.
  2. Open MetaMask’s approval notification – A pop‑up window appears showing the token, the dApp’s address, and an “Allow [dApp] to spend your [token]?” message.
  3. Click “Edit” (or “Custom”) next to the allowance amount – By default, MetaMask shows a high allowance (often unlimited). Click the pencil icon or the “Edit” button.
  4. Enter your custom allowance – Type the exact number of tokens you want to authorize. For a trade of 50 USDC, enter 50. For safety, add a tiny margin (e.g., 50.05 USDC) to account for price fluctuations or slippage. Do not leave commas or decimals unless the token uses them. MetaMask will automatically adjust for decimals (e.g., USDC has 6 decimals, so 50 becomes 50,000,000 in base units).
  5. Confirm the transaction – Review the new allowance in the confirmation screen (it will show “Custom” instead of “Unlimited”). Sign the transaction and pay the gas fee. Once confirmed, the dApp can spend up to exactly that amount.
  6. Complete your original action – The dApp will now call transferFrom to pull the tokens. You have successfully avoided an infinite approval.

If the dApp requires a higher allowance later, you will need to approve again. This is a small inconvenience for significantly better security.

Alternative Method: Using Etherscan’s Token Approval Tool

If you want to set a custom allowance without interacting with a dApp (for example, to pre‑approve a contract you intend to use later), you can use Etherscan’s “Token Approval” tool. This is also useful if MetaMask’s built‑in editing is not working as expected.

This method gives you full control but requires understanding of token decimals. A safer alternative for revoking allowances is a dedicated tool like Revoke.cash—though editing via the contract write is doable.

For most users, the direct MetaMask approach is simpler and less error‑prone.

How to Verify and Revoke Existing Allowances

Even after you start setting custom allowances, you may have old unlimited approvals still active. To verify them:

To revoke via MetaMask directly:

  1. Send a transaction to the token’s contract address with a data payload that calls approve(spender, 0). This is advanced.
  2. Easier: Use Revoke.cash’s “Revoke” button. It will pop up a MetaMask transaction that sets the allowance to zero.

Always revoke allowances for dApps you no longer use, or those with questionable security. A best practice is to keep a minimal allowance only for active protocols and revoke all others.

You can also set custom allowances to a future‑proof amount—like slightly more than you think you’ll need—to avoid frequent re‑approvals. But revoke any that are truly infinite.

Security Best Practices for Allowance Management

By adopting these habits, you significantly reduce the attack surface of your portfolio.

Troubleshooting Common Issues

Issue: MetaMask won’t let me edit the allowance.

Some dApps use a custom approval UI that bypasses MetaMask’s editable prompt. Try starting the approval from a different part of the dApp, or use a block explorer as described above. Also, ensure MetaMask is updated to the latest version.

Issue: I set a custom allowance but the transaction still failed.

Check that the amount you entered is in the token’s decimal format. For example, USDC uses 6 decimals—to approve 50 USDC, you should enter 50, not 50000000 (though MetaMask will usually convert for you). If the dApp expects a different unit, the approval might be too low. Try increasing the allowance by a small margin (e.g., 0.5%).

Issue: I accidentally set an unlimited allowance. How do I fix it?

Immediately revoke that approval using Revoke.cash or via the token contract method. Then set a fresh custom allowance.

Issue: The dApp requires frequent approvals.

If you interact with the same dApp often (e.g., a lending platform that auto‑harvests), consider setting a larger custom allowance (like 10–20× your usual order) to avoid repeated gas costs. This is still much safer than an unlimited one.

Frequently asked questions

Does setting a custom allowance cost more gas than an unlimited one?

No. The gas cost for an approve() transaction is the same regardless of the amount. The only difference is the data encoded in the function call, which is nearly identical.

Can I set a custom allowance after already giving an unlimited one?

Yes. You can call approve() again with a lower amount to overwrite the previous allowance. The new allowance replaces the old one entirely.

What if the dApp says the allowance is 'too low'?

The dApp will show an error when trying to call transferFrom if your allowance is insufficient. You’ll need to approve a higher amount—either by re‑approving with a larger custom number or (if you trust the dApp) using unlimited temporarily.

Does revoking an allowance cost gas?

Yes. Revoking an allowance (setting it to 0) is an Ethereum transaction that requires gas. The cost is typically the same as any standard token approval.

Are there any tokens that don't support custom allowances?

All standard ERC‑20 tokens support the approve function, so you can always set a custom amount. Some non‑standard tokens (like certain rebase or fee‑on‑transfer tokens) may have quirks, but the approval mechanism remains the same.

Track the entities behind the concepts

DeFi Intel maps 11,000+ protocols, tokens and companies to a typed knowledge graph — with live data, incidents and regulation.

Entities mentioned