I present you with a situation ⏬

You're making a payment at the market, and the employee makes you a proposal:

👨‍💼 "You come to buy every day, and I've been thinking... why don't you leave your wallet 💵 here with me, and every time you come to buy, I'll charge directly from there?" 🤨

If you're like most people, you'd probably consider this as something completely absurd, and you'd likely react with disbelief to the idea, maybe even feel like giving the person a punch 😵 before leaving the place 🚪😡

But... what would you think if I told you that many of us do/did this every day without any complaints? 😳

The magic word is ✨approve✨; it's a function that grants a smart contract permission to "spend" our tokens 💸

It's commonly used for exchanges or adding liquidity to pools/vaults

Many will be astonished to discover the number of smart contracts that have authorization to use tokens from their wallets 😱

(self-granted authorization 👊)

It's like leaving our wallets, credit cards, and blank checks at every place we visit 🤦

Let's look at an example to understand how it works 👇

We have the need to exchange DAI for USDC and decide to use Uniswap🦄 for this operation. We'll use Rabby 🐇 wallet for this example 🔽

1️⃣ We select the amount of DAI we want to exchange.

2️⃣ We click "Swap" and then "Confirm Swap."

3️⃣ A small message appears, which we usually overlook 🙄.

4️⃣ At the same time, the wallet window opens.

5️⃣ We look at the window and think, "There's a lot of data... it must not be important... I'm in a hurry... I'll sign it right away" ✍️.

6️⃣ We proceed and complete the desired exchange.

End of the story, right? 😬

But NO, the reality is that without even considering it, we've just handed our wallet, checkbook, house keys, and a blank promissory note to the market employee 😅

Let's examine closely what that signature we made without much attention implies.

As can be seen in that scenario, we granted UNLIMITED permission to the Uniswap contract to spend all the DAI we own or will have in our wallet ❌

Now, let's consider what action we should have taken instead ✅ 👇

Within Rabby window (which shows the amount 👀), we have the possibility to adjust the spending limit we want to authorize:

1️⃣ Click "Edit"

2️⃣ Remove the default amount

3️⃣ Enter the precise amount of the token we want to exchange right now, just as we would in the market 😁

4️⃣ Press "Confirm"

5️⃣ Verify that the approved amount has been adjusted

6️⃣ Sign and then proceed with the exchange

As we can see, we have now authorized only 10 DAI ✅

Therefore, once we complete the exchange, the spending limit will be consumed, and the contract will no longer have the ability to use more tokens from our wallet 👍

Unfortunately, some wallets, like Rabby's 🐇, suggest granting permissions for unlimited amounts by default ♾

However, others, like Metamask🦊, in their latest update, ask us how much we want to authorize beforehand 😉

And at least the 🐇 wallet offers us the option to modify that value, as most wallets, especially mobile ones, don't even give us the option to do so and only offer the option to authorize unlimited spending 😢

This last aspect should be considered when selecting a wallet 🫡

But what if I've already granted unlimited spending multiple times for different tokens and contracts? Or if my wallet doesn't give me the option to choose the amount when granting permissions? 😭

I'll explain it in my next post, so let me know if you're interested in this topic with a ❤️ Like and 🗨️ Comment.