Gas Tutorial: How to Set Your Own Gas Prices

Maï Akiyoshï
11 min readOct 1, 2021

--

One of the questions that we are asked the most about is gas, such as how much gas should I pay, why is gas so expensive, and what is gas anyways!?? It makes sense that gas would be such a popular topic, since whatever you do in this space, from sending money, to buying NFTs, to minting your NFT, to staking your ETH, and so on, all activities you do on Ethereum blockchain will involve gas. And the unfortunate reality is we see lots of people spending much more money on gas than they need to, so we decided to create a guide on how to set your own gas price on Metamask.

If you are more of an auditory learner, here is the video we made explaining how we save on gas (the first 5 minutes explains most things, the rest is optional and more advanced).

What exactly is gas?

The name “gas” came as an analogy from actual gas for a car, and the concept is very similar. If you were to drive to a different city and simulate the total cost for gas, 2 things you will need to think of is distance and price per gallon/liter of gas (assuming you always use the same car so MPG stays the same). The total gas price will be higher if: 1. you are traveling a longer distance, or 2. the gas price is higher.

In Ethereum, the same concept can be applied. The distance is in other words, how much work a car needs to do. In Ethereum, it’s how much work the blockchain needs to do. For example, the simplest transaction (work) on Ethereum blockchain is sending money from one person to another, which takes 21,000 units of gas. On the other hand, more complex transaction such as minting an NFT will require more units of gas, because the program required to be executed for the transaction is much more complex and requires more computing resources.

Just like you can’t change the distance between two cities, you can’t change the amount of gas units required for an Ethereum transaction. However, just like you can wait for the gasoline price to fall until you fill up your car tank, you can wait for the gas price to drop until you make a transaction. Metamask provides a way to set the gas price to be whatever the amount you are willing to pay and will wait to execute the transaction until the gas price hits the price you set, and we are going to show you how to do exactly that.

How to manually set a gas price

Let’s try placing a bid on some art on Foundation. Once you hit the “Place a bid” button, the Metamask Chrome extension pops up (I am assuming you already have the Metamask extension) and you will see this screen:

You will see the suggested gas price, which changes from time to time depending on how busy the network currently is. In order to change the gas price, click the “EDIT” button. You will now see the radio buttons of Low/Medium/High. Let’s ignore this because the difference between them is just a few cents and doesn’t make that much of a difference. So go straight into “Advanced Options”, and you will see the following options:

Here is a quick explanation of what each concept means:

  • Gas Limit (unit) : The maximum units of gas you are willing to use for this transaction. Units of gas are multiplied by the “Max fee” to equal your total overall gas price, just like with a car, the number of gallons of gas you use is multiplied by the price per gallon of gas to calculate your total cost for a trip. Never change this value because this is the amount of work it requires to complete the transaction, and just like you can’t change the distance it takes to drive from California to New York, you can’t change how much work a certain transaction requires. (Remember the simplest transaction, sending money from one address to another takes 21,000 units of gas, so you can see placing a bid on Foundation takes a lot more work (~72,600 units [which includes some margin of error in estimation, so in reality it’s slightly less]).
  • Max priority fee aka “miner tip” (GWEI): This goes directly to the Ethereum miners (people who secure the blockchain and process transactions) and incentivizes them to prioritize your transaction over others. Miners, who are the ones that select which transactions they are going to process, will prioritize the transaction they process based on the miner tip, because that’s the revenue they are going to earn. Therefore, making this higher will incentivizes miners to pick your transaction. Typically, however, you don’t need to really make this anything higher than 1.5 gwei, so no need to change this.
  • Max fee(GWEI): The maximum amount you’ll pay (base fee + priority fee). The base fee is a predetermined amount set by the Ethereum blockchain as the minimum required fee (this fee is burned and doesn’t go to miners) for any transaction to be processed in a given block on the blockchain. If your base fee you set for your transaction is below the base fee required for a given block, no matter how high your priority fee is, it will not be processed by that block.

What you will need to change here is Max fee (GWEI), which is how much money you are willing to spend total for gas. By default, it displays the current going price of gas. You can change that to whatever price you are willing to pay for gas and the transaction will go through when the going network gas price falls to that level.

As of September 2021, we usually set the gas price between 35 and 40 gwei for transactions that don’t need to go through immediately and that you are willing to wait up to ~24 hours to complete. If you set your gas fee this low, it will probably show the following message:

Don’t worry about this — it is just saying that it won’t go through with this gas price right now because the network is currently busy. When the network congestion falls down, the gas price will also fall down and when it falls down to the same price as you set, the transaction will execute.

**If you are using a hardware wallet such as a Ledger or a Trezor, the UI may look slightly different (legacy gas price mode). It may only show Gas Limit and Gas Price. In this case, simply set the gas price to be whatever amount you are willing to pay, and treat it as essentially the same thing as Max fee in the regular gas screens shown above.

Once you do this, you will see the pending transaction in your Metamask wallet history (Please note that when there is a pending transaction, unless you cancel your transaction, you can’t make another transaction) :

As you can see, there is an option to “Speed Up” the transaction, so in case the network keeps being congested much longer than expected and you can’t make the transaction by the time you want to, you can always speed up the process by pressing Speed Up and set a new gas price. Because you can always speed up transactions later, it’s always worth setting the gas price low at first and then speed it up later if needed.

Note: when you are trying to mint a super popular PFP project or something similar with a lot of people trying to make transactions all at once, you might want to set the gas price much higher than you usually set, not lower, because it’s first come, first take, and if the transaction doesn’t go through by the time all the NFTs in the project get minted, you won’t get what you want. I’ve made that mistake. So what you should set a given transaction’s gas price to is a case-by-case thing.

In case you don’t want to see the Low/Medium/High settings and just want to set the gas price manually straight away, you can change your Metamask settings to do so. Click the top right icon in the Metamask browser drop down and find the menu “Settings”, click it, then click “Advanced” on the next screen. Here, you will find the option “Advanced gas controls”. Turn this on and close the settings panel, and now you won’t see Low/Medium/High anymore, and can just set gas prices directly.

How to pick the right gas price to set

At this point, you might be wondering, ok, so I understand that a good gas price to set is 35 or 40 as of right now in September 2021, but the congestion and gas prices of Ethereum fluctuate all the time, so how can I pick the right gas price on my own in the future?

Great question! Here’s how.

First, go to the Etherscan Gas Tracker. You can see Low/Average/High here, but that’s not what we should look at because it’s based on the current gas price, just like the Metamask suggested gas fee. What we should look at is the lowest gas price everyday, because that is the minimum amount we have to pay to have a transaction go through in the next ~24 hours. How do we find this information? Go to Historical Gas Oracle Prices, where you can see the historical data of Max/Avg/Min gas prices for each day.

As of 9/30, the minimum gas price is 30 gwei, which means, at some point during that day, the gas price fell down to 30 gwei, so if we pay anything above that, the transaction would go through at some point. To avoid the risk of not going through at all, it’s good to go a bit higher than the minimum as every day the minimum gas price fluctuates, and there’s no guarantee that prices will be exactly as low as they were today tomorrow. Therefore, in this case, a good gas price to set can be 35 or even 40.

How does the blockchain know which transactions to process?

When you speed up a transaction, you will see multiple pending transactions on Etherscan.

How does the blockchain know that both of these are for the same transaction and cancel all the other pending transactions once one of them goes through (the transaction with the highest gas price will be the one that processes)?

Here is where the idea of a nonce comes in.

Nonce: A sequential running number for all the transactions ever executed for a given Ethereum address, beginning with 0 for the first transaction. For example, if the nonce of a transaction is 10, it would be the 11th transaction sent from the sender’s address.

In other words, the nonce is decided based on how many transactions your address has ever completed in the past. So if you have made 10 transactions in the past, your next nonce will be 10 (not 11, because it starts from 0).

The nonce of a given transaction can be seen on Etherscan (here is an example transaction — you will need to click the “Click to see More” at the bottom of the page to display the nonce). If you see all the transactions you have made on your address (Go to https://etherscan.io/address/{Enter your Ethereum address}), you will see that the earliest transaction you made has a nonce of 0.

Going back to the point about how the blockchain will know which transactions should replace each other and not execute consecutively one after the other, the nonce is used to distinguish between these two things. If you look at 2 pending transactions (the one you made first and the second you made to speed up the first transaction), both transactions will have the same nonce. When the blockchain processes one of these transactions, all the other pending transactions that have the same nonce will be canceled/dropped.

Hack: How to replace a transaction with a completely new one

This might not be relevant to everyone because this is a more specific, advanced situation you may or may not encounter: Replacing the transaction with another transaction. Here’s one example case: you tried to buy a piece of art, placed a bid, and set the gas price to be lower so that it will go through later and not immediately. 5 minutes later, you found another art piece you like a lot more. You want to place a bid for the new art rather than the art you have already placed a bid on. Good news is you can, if the previous transaction hasn’t gone through yet. This is another benefit of setting low gas prices — you can cancel the transaction or replace it if you change your mind later!

First of all, you will need to change one setting from the settings tab we mentioned earlier. Go to the icon at the top right of the Metamask dropdown screen, and select Settings > Advanced, then turn on the setting “Customize transaction nonce”.

Then, you place a bid on the new art piece you found just as normal, but once the Metamask screen pops up, you will see a new field called “Custom Nonce”.

Now, go to the Etherscan, open the pending transaction you want to replace and check the nonce on that transaction. Copy that nonce and paste it into the Custom Nonce field here. For instance, if the nonce was 3 on the pending transaction you were trying to replace, change the custom nonce on the new transaction to be 3 as well.

Also, make sure to set a slightly higher Max priority fee (just 1 more gwei should be sufficient) and Max fee (+10 gwei is usually safe) so that the new transaction will be prioritized over the old one. Once you do that, the blockchain will think that the old transaction and new transaction are trying to do the same thing, so that only one, the one with higher fee, which is the new transaction you want to complete instead of the old one, will go through.

One more thing before you go

The gas price on Ethereum fluctuate a lot nowadays, and the reason why the gas price goes up is because more people are making transactions at the same time. If you want to know what is going on, one way to know is by using icy.tools. This tools displays what NFT project is trending in the past hour (you can even see what’s been trending in the past 15 min if you pay for premium (0.03 ETH/mo)), so you get some idea of what people are aping into. Pretty neat tool :).

Hope this was useful!

If you are interested in learning more about NFTs, check out our resource page here or join our discord to learn more from our members.

Interested in making your own NFT collection? Check out the link below:

  • Heymint Launchpad (https://join.heymint.xyz/): A free no-code platform that allows you to launch an NFT collection without any programming skills (NFT art generator, smart contract builder, create mint website)
  • HeyMint Allowlist manager (https://heymint.xyz/): A biggest free allowlist manager for launching your NFT collection.

Curious Addys Trading Club

--

--

Maï Akiyoshï

CEO/co-founder of HeyMint (https://heymint.xyz), empowering NFT creators by building a tool to allow them to build NFT collections without any coding skills.