Skip to main content
iCrypto

Crypto news, costs and deadlines

How to Set a Custom Spending Cap in MetaMask for a Dapp

How to set a custom spending cap in MetaMask: replace the dapp’s suggested amount with your own before approval, then confirm and check the allowance.

iCrypto Editorial4 min read

How to Set a Custom Spending Cap in MetaMask for a Dapp

To set a custom spending cap in MetaMask, replace the suggested amount on the spending cap request screen with your own number, then confirm the approval. That number becomes the ERC-20 token allowance: the amount the smart contract can pull from your wallet.

You can check the result on the same network in revokecash, which lets you see whether the dapp’s allowance matches the amount you chose. Before you begin, make sure MetaMask is on the network the token uses, your wallet has the network’s gas coin for transaction fees, and you know how much the dapp needs for the action you plan to take.

Which approval are you about to grant?

Start by reading the spender and token shown in MetaMask’s spending cap request. The spender is the smart contract asking for permission, and the token is the asset the contract wants to use. Make sure they match the dapp action you just started.

  1. When the dapp opens the MetaMask request, check the token name and spender details before changing the amount. An approval gives that spender permission to pull the named token from your wallet, up to the allowance you confirm. If the token or spender does not match the action you intended, stop and return to the dapp to check what triggered the request.

What amount should you enter?

Enter enough to cover the full amount the dapp’s next transaction will pull, including any fee it shows. The spending cap is the allowance passed to the token’s approve() call. A smaller cap limits the contract’s permission, but it can also leave the next transaction without enough allowance to complete.

  1. Select the amount field in MetaMask, clear the suggested value, and type your custom cap. Use the amount shown in the dapp as your reference. If the dapp also displays a fee that will be paid from this token allowance, include it in the total you enter.

    Note: A cap below the amount the next transaction pulls can make that transaction revert. You may still have spent gas on the failed transaction, because the network charges for processing it. For instance, if a dapp shows a token amount and a separate fee, entering only the token amount can leave the allowance short. Match or slightly exceed the full amount shown so the approval is usable for that action.

Are the approval and fee ready to confirm?

Before confirming, review the amount you entered and the transaction fee MetaMask displays. The amount is the token allowance you are granting; the fee is the gas cost for submitting the approval transaction. You need the network’s gas coin in your wallet to pay that fee.

  1. Confirm the approval in MetaMask once the spender, token, custom cap, and fee look right. The approval transaction must be confirmed onchain before the dapp can use the allowance. Wait for MetaMask to finish processing it, then return to the dapp and retry or complete the action you started.

How can you check the allowance?

Look up the approval on the same network as the token and dapp. The confirmed cap is stored onchain as the allowance for that spender, so the network matters when checking it.

  1. Open revokecash, select the network you used for the approval, and find the entry for the token and spender you checked in MetaMask. Confirm that the listed approval shows your custom number rather than “Unlimited.” If the entry does not appear yet, allow time for the approval transaction to confirm and check again on the correct network.

When revokecash lists the allowance with your chosen amount, the approval check is complete. You can now decide whether that cap covers the dapp action you intended, and proceed from the dapp if it does.