Ethereum 101 - How to save gas fees?
So when you are doing anything with the Ethereum network (that isn't just reading from it) it will cost you gas. And gas fees can be pricey (you know this). It can be quite painful to see how much gas one is spending so I want to dedicate an article on how to (potentially) save some gas fees.
Gas is used to process things in Ethereum. Part of it goes to the miners (and later the stakers) of Ethereum and part of it is burned to keep the total number of Ethers from exploding (deflationary). If you have ever tried to mint a popular NFT just when it came out you know very well that gas fees can easily go up to the thousands of USD. Similar to when you deploy a contract, it can also easily get very very expensive quickly.
So how do you save gas fees?
To answer that let's first quick talk about how gas is calculated. We have the following components:
Gas limit: This is the maximum of gas you are willing to spend. Usually, websites that want you to mint will set this appropriately to what you are trying to do. The gas limit changes based on what it is and how complex the transaction is. Minting 5 NFTs in one transaction will require a higher limit than minting one. Usually, you should (!) not change this unless you know exactly what you are doing. If the gas limit is reached and the transaction is canceled you will lose all fees spend so far, so changing this is potentially dangerous for you.
Base fee: This is the amount of money you are willing to spend per gas unit. This is typically measured in Gwei. 1 Gwei is 0.000000001 ETH. (just a convenience thing to not have super small numbers for our purposes here).
Priority fee: This is an additional amount you can define to make your transaction go through faster (miners will process you before others). Especially in timely mints, this gets quite important (and expensive).
So let's look at a recent mint transaction of mine:
You can find the full transaction here.
Now, what do we see? We see that ETH had a price of 2,638.81 USD / ETH. We also see that the gas limit was set to 454,286. The gas fees were set to 219 GWEI with a max (through priority) of 221 GWEI. Additionally, we only needed 60% of the gas limit, which is 274,549.
The total price of the gas fee is now calculated as follows:
274,549 * 221 = 60,675,329 GWEI
60,675,329 Gwei = 0.060675 ETH = USD ~160 in gas
领英推荐
So this is USD 160 in gas fees for this mint. I took all the values Metamask and the website suggested for this mint and it was finished within 40 seconds (as you can see on Etherscan).
So what could we optimize here? Changing the limit has no effect on the overall price because running this same transaction again would still require the same amount of actual gas (274,549). So the only variables we can actually change that make sense are gas price and priority fee.
What are the consequences of changing the gas price?
Fundamentally only this: If our gas price is under what the most recent gas prices are at we will not be processed immediately. We will only be processed once gas gets under what we set (why would a miner process us if we are not willing to be the market price?).
To demonstrate it (and to save money) I minted again, the same collection, everything is the same, but this time I adjusted the gas price. Gas was at around 160 - 220 GWEI at the time. But I was in no rush and I did not want to spend more money than necessary. So in Metamask, I adjust the gas price. You can do that by clicking on "Edit" when Metamask estimates the gas fees and then selecting advanced options, like this.
So for the transaction in question, I set the gas fee to 120 GWEI, which was a good bit under the market rate of 160 - 220 GWEI. So I knew that I would not be processed quickly, but that wasn't my intention anyway. Check out the overall effect on price:
Notice how the only difference is the gas price (120 Gwei) and how all other values remain the same. However, let's run the numbers again:
274,378 * 120 = 32,925,360 = 0.03292536 ETH in gas. That is 88 USD!
So that saved me roughly 50% of the gas fees compared to the first transaction. Isn't that interesting? Now note that this transaction took a total of 34 minutes (!) and not 40 seconds. You can find the second transaction here and you will see that it in fact took its sweet time. But that is okay with me here because I wanted to save money and so I was willing to wait.
Note that I minted a collection where I was whitelisted and so I wasn't really in a time crunch and knew that my spot would not just disappear. In many cases, you don't have this luxury necessarily. But when you do, why spend more than you have to?
All right, take it with a grain of salt, none of this should be taken as literal advice on how to set your gas fees but I hope you get the concept of how you don't always just have to take things the way they are set in front of you. Understanding gas fees can quite literally save you thousands of dollars. Please leave your comments, I love to hear from you!
Founder & CEO of Chainvest | SEIS/EIS Assured | Tokenizing Private Equity
3 年Polygon network has been flawless and its a shame that there is a community of collectors that believe that it equates to inferiority in terms of NFT value.
Marketing Strategy & Digital Marketing | Author | Newsletter writer || Personal Account - no BMW related requests please.
3 年It would be interesting to know more about Polygon and how/why is minting with Polygon free on Opensea.