Krystal Blog Logo

The Ultimate Guide To Token Approvals (Why They’re ESSENTIAL)

●   7 min

If you’re performing any transaction Krystal or any decentralised application (DApp) for the very first time, you may notice that you’ll need to perform an ‘Approve’ transaction first.

Dmgf0 BafMTswXDoisO7xz5LWAxQ 4ojS5p5JewGWk7VZAzXtJObQAq82cOUDm5p3kQIZ1nA6oNmW1 VyLgmMNyR f4PQzsYMY6rlFDLX6hb0kyXToeJrrHGjTxC

Why do you need to do this transaction, and does it cost a lot of gas fees?

Here’s everything you need to know!

What is an ‘Approve’ transaction?

An ‘Approve’ transaction grants a smart contract the permission to interact with the tokens in your non-custodial crypto wallet. 

All decentralised applications (DApps) are built on smart contracts, which provide you with an interface to use these contracts on the blockchain.

This includes any DeFi platform, game, or NFT marketplace.

You will need a non-custodial wallet (like Krystal or Metamask) to interact with these DApps and smart contracts.

However, before you can use any functions on the DApp, the smart contract needs to view and retrieve the tokens that are in your wallet.

Here are some examples of how a smart contract interacts with the tokens in your wallet.

FunctionHow the smart contract interacts with your wallet
SwapThe decentralised exchange needs to retrieve the token balance in your wallet, and withdraw the funds from your wallet to deposit the swapped tokens
DeFi LendingThe lending platform needs to retrieve your token balance and withdraw the funds to deposit into the lending smart contract
BridgeThe bridge needs to retrieve your token balance and withdraw the funds from your wallet to deposit the same token in your wallet, but on another chain
NFT MarketplaceThe marketplace needs to retrieve your token balance and withdraw the funds from your wallet to allow you to purchase an NFT

Before a smart contract can interact with your token balances, you will need to grant permission via a token approval.

A token approval can be sometimes referred to as an allowance.

This approval will be recorded on the blockchain, and acts as proof that you were the one who gave this permission.

As such, it is extremely important that you keep your private keys and seed phrases secure. Anyone who has access to either one can give token approvals to any smart contract!

Why do I need to approve a token before performing a transaction (e.g. swapping)?

By default, all smart contracts are unable to interact with the token balances in your wallet, apart from the native token of that network. Each approval transaction will give the smart contract permission to interact with a specific token in your wallet.

If you are performing a transaction with a token for the very first time, this means that you will need to process 2 transactions:

  1. Approving the smart contract to interact with your token balance
  2. The actual transaction that you intended to do (e.g. Swap, Earn or Bridge)

After approving a token, this will allow the smart contract to transfer the tokens from your wallet to theirs, where they can perform any transactions including token swaps, lending or bridging.

It can be rather confusing at first, as after the approval transaction, you may think that the transaction is done. However, that is not the case!

You will still need to confirm the actual transaction in a separate blockchain transaction!

When does an ‘Approve’ transaction occur?

You may want to note that a new approval transaction is needed for: 

  • Every token you intend to use
  • Every smart contract you interact with

For example, let’s say you want to swap USDT on the Avalanche network using Krystal.

x iGux7pxv8TdNWpRaqb sRESlYumwyGYXPTpOi4GY9a pbdJcQmA4dL8Gju8erOYexVw1CE1U4M V9o1vpYLiQez5uI5fBKvyegHryL3LduAEMXj5QfUApa9qmn1VUg0QDNG7jJzyzDxzvSJO K2OfS3lE6bYzAJtm s2AFTe1256IwQmoOAE4aKAOow

You will need to approve Krystal’s smart contract first before you can perform the swap.

w h51rk YHs55aOoXl6hIW076QzrqqYyxcqA guoSWesgyBhtC2CVn35hYjOOGj N7ZhkiCnSuiUj3U25opAxP gN ESr27m9 MhJ MKsjAeOyI8tpAET2o Ho7wMO8Qe8Mv8tpLXbg6EUJZfSGSsE djsnEGcDbGWmRMLqYnGAQ3U9f3wuQ5aGdAvjIEw

If you are looking to swap USDT on another network (like Polygon), 

V1IueZ5qvqowgIFBCyyWAbVo8pnMpj0n6OATqH5TY4UwKkEREbyZG6g1t9ncrFvXTrkdYVS97 K38n13 WoQ3jNj1tzeIfPznLhzORNxyjmDcCr1ptgq4YWYNEoYgro1Ym84PmkhDnTNHG6gEx Tp b2W4IvS3tYxWjMFIh0ceD MMA LP qBdCCLlzICg

you will need to confirm another approval transaction.

The same applies if you are looking to bridge USDT from Avalanche to another network (like BNB Smart Chain),

where you’ll need to approve yet another one!

hZ9OMKkkbXoNJTd03Xpe1gRYeib B3HI5G7Slzb6dGFP5G3jhQvlviDNuZjuhfHPfsEJSbpDFmJ55eyC3v hM4FrRAfZmXueQUwz24AqlWxZ4c47wtIDm31I30xywshm7

Each transaction is usually only done once, unless you have reached the token limit (which we’ll cover later).

The only exception to this is when you are looking to transact using the network’s native token. In this scenario, no approval transaction is required.

For example, if you are looking to swap BNB on the BNB Smart Chain to another token, you can do so right away without any token approval.

Approvals can be limited or unlimited

In most cases, when you are approving any transaction, the default for most wallets is that you will be approving an unlimited allowance.

uZkbRB7oJQFhHU 5mu07NqpxC8THoBnVWGQPLWtS2bwpikxeAek3Ptc4 R0ntsn7zx ETpY4PxS3jRutTmXh PaA30Yewz Df1IjEZeL5qngNU

In the screenshot above, the amount of USDT is equivalent to an infinite amount, which suggests an unlimited approval.

This can be advantageous as you only need to approve this allowance once, saving you on gas fees!

Usually, this would not matter if you are only interacting with trusted DApps, like Uniswap, Pancakeswap or Krystal 😉.

However, there are risks when you approve an unlimited allowance for a malicious smart contract.

The funds in your wallet can be accessed by this smart contract, so it has the potential to drain all of them!

Some token approvals can be limited as well.

For example, let’s say you set a limited approval for 2,000 USDT on Uniswap. This means that Uniswap can only withdraw up to 2,000 USDT in total from your wallet.

If you want to swap more than 2,000 USDT, you will need to approve another allowance.

⚠️ Be careful which contracts you’re approving

While you are interacting with multiple protocols or decentralised apps (DApps), you may be required to approve multiple smart contracts for them to interact with your wallet.

However, some of these contracts can be malicious, and are designed to drain your funds once you interact with them!

Multiple hacks have occurred this way, where hackers create phishing sites that look similar to the actual platform.

Here are some examples of Pancakeswap,

and CoinMarketCap.

You may have mistaken them for the actual site, and after approving the contract, the smart contract may be able to drain all of your funds!

Some examples include:

As such, it is very important that you double check the URLs of the DApps you are interacting with. If they look suspicious, please do refrain from connecting your wallet and approving any transactions!

While having a non-custodial wallet is great for having full control over your funds, you are also fully responsible for the security of your funds.

If your non-custodial wallet gets hacked, no one will be able to help you!

This is in contrast with leaving your funds in a custodial account, such as a centralised exchange like Binance. The majority of your transactions are off-chain transactions, where they are done within the platform itself, as compared to off-chain transactions.

In the event of any ‘bad’ transactions that are made on a centralised exchange, the custodian is still able to reverse them. However, the same cannot be done on a non-custodial wallet!

As such, do be really careful when you are approving any new contract, and it will be good to double-check if you are interacting with the actual site or a phishing one.

Approving is different from connecting your wallet

When you connect your non-custodial wallet to a DApp, that DApp is only able to view your wallet address.

9AOMPqIZVOfqn22vj4fWhjLwKamuDUcrNq3z5HnawsN8ybwOEkVOgeyjWovaoQPB oLW7XAr9qj5SVg1AuKs1cXiwa3d 71CLKHsM7 LKwJSQJlndn9FPxPlc6qe5LQ JrMVgdL RqnxmLV6NUV3VD31HB0FvhYPhjkccVAQy5LLjNBv w9AaRqEZ4WqnA

As such, connecting your wallet is different from approving a token allowance.

Connecting a wallet is the first layer of security, where the DApp can only view your wallet address.

If you do not approve any allowances, the DApp cannot interact with your token balances in the wallet.

As such, disconnecting your wallet from a malicious DApp does not mean that your wallet is safe!

You will still need to revoke the token approval that you have given to that DApp, and here’s how Krystal’s revoke approval function works!

Introducing: Krystal’s Token Approval tool

You can view any token approvals that your wallet has using our Token Approval tool.

After connecting your wallet or pasting a wallet address on the search bar, any token approvals across all supported networks will be shown here.

newmYFHWf2LD50cxjaHIy92DTcd0ROiHK41l2Q98Vtvg2ofvLyNplFbw4I6SHRLhiaJN5YUHLQK9iWNHYZsaSQEHwnThhDnoaBs8GZV1vl7WwUSYJSD 5DYX7h7H0O7Aj9V6 2m9tPfg1BlVrBEzxLN28HzwRi8 VC a4zUfQlgBYRRH34rU9GAJtKJJCA

The total allowance value indicates the total amount in your wallet that can be accessed by smart contracts that you’ve previously approved.

You can select the smart contract under ‘Approved Spender’ to view the smart contract on a block explorer.

3njUqQ4LqIHBlLhO5AAafABFc9z1dFm8Ldrgxgh2Z92V0lfP2XqpDmWmG5h 2CIRNTSW XceMEWMAcD6EWTkWAfWwTK 823BpvhlO3CvoMalt2TUkR3Xz1biEejJYZDFghNRAyGq4Qp6L7l 9EfHOpx9Cms0MVeUxc2QfHF7SrVjzNHiC 7oOGedvlBBg

For example, this smart contract (0x051DC16b2ECB366984d1074dCC07c342a9463999) is referring to the Krystal Router, one of the smart contracts that you’ll use on our platform.

YJgNCuK633QI8CqkNcAinFokQH 04zHoJLWrvu1mwi7359Ke1ToqgFUI7aQqQl9KjNV0LzxOJqKfAbUiOx jlW6mfBoKYCXByTS1PvJ9vqS1mD7q5zPbv24t0x3xoDfRJohx itNLf0XQFmW8I7sXvZ1TretrYKH87yTdpP3 mZ6v6oPUVCrLqvw3uhArQ

You can choose to revoke any smart contract by clicking on the revoke button.

jlRUe7kTub9GefMjEj6UYwYspOFTm4n01CHDa xroBJtlO50PdNoRKkfdzN82bWnQ7CWVDpje QdkAMYpV7hf94tNHj0wUT55wd3k l2ownalRPrtCO

Gas fees are needed to process this ‘revoke access’ transaction, so don’t forget to have some of the native tokens in your wallet!

Once the transaction is confirmed, the smart contract is no longer able to interact with your token balance!

Conclusion

Approving token allowances is necessary for you to interact with any DApps in the DeFi world.

However, it is a double-edged sword, as any malicious smart contract has the potential to drain all of your funds if you’re not careful!

Some of the ways to protect yourself from such contracts include:

  1. Paying attention to any possible phishing links
  2. Not approving any allowances for suspicious smart contracts
  3. Using Krystal’s token approval tool to revoke a smart contract’s access to your token balances

🔍 Navigate the DeFi Space NOW with Krystal!

Start your journey NOW on Desktop, iOS or Android

📱 Social Media

How do you rate this article?

1
0

Leave a comment

Your email address will not be published.