You want to buy new shoes and go into the store with one mental note “ $200 is the maximum I’m willing to spend” so you end up looking for shoes within that price limit. It’s easier to set a limit for physical items, but how are gas limits set in an Ethereum transaction, and how to choose the right limit? Before we delve deeper you need to understand why gas fees are required in the first place.
Why Do We Use Gas Fees?
Gas fees are used for two purposes to keep the network secure and to incentivize the validators. These fees ensure that whoever uses the blockchain can not send spam, and rewards the individuals who choose to maintain the blockchain. These individuals are called miners or validators. They verify and process transactions on a certain blockchain, whether it’s Bitcoin or Ethereum. On the Ethereum blockchain, some of the tasks validators do are related to ETH transfers and minting NFTs. You can learn more about blockchain validation here.
Gas fees, also called transaction fees, are calculated in Gwei, a subunit of Ethereum- it’s like a penny to a dollar. Think of a transaction fee similar to the fee you pay for a money wire transfer, in which you pay the service provider for using their network. In this analogy, the network is the blockchain, and service providers are the individuals transferring and documenting your transactions in the blockchain ledger.
What is Gas Limit?
In calculating gas fees there are two important parameters, gas limit and gas price. “Gas limit” is the maximum amount of gas you permit the validator to use. The higher you set it, the more work the validator is expected to do. It is used to guarantee that the transaction will be executed. If the operation uses less gas than the set limit, Ethereum Virtual Machine will refund you. “Gas price” is the price per unit of work done. Gas price is calculated in Gwei – which is equal to 1/10⁹ ETH. Usually, users will pay between 1–60 Gwei per unit of gas, depending on how overloaded the network is. Here’s the basic formula to figure out gas fees in a transaction:
Transaction Cost (in ETH) = Gas Limit × Gas Price × (1/10⁹)
Complicated transactions that involve transactions related to smart contracts, such as calling a function from a smart contract or publishing a smart contract, require more computational work from validators. That’s why they require a higher gas limit than a simple payment. A standard everyday ETH transfer or NFT mint requires a gas limit of 21,000 units of gas.
How to Set the Gas Limit?
Usually, the gas limit is set for you by default according to the nature of your transaction whether it’s a transfer or mint, however, you can set it manually. Keep in mind that if the limit you manually set wasn’t enough you run the risk of the operation failing and spending money for nothing.
During peak transaction times, many users set their NFT gas fee limits high to ensure their transactions are validated. That usually happens during a hyped NFT collection drop, when everyone is rushing to mint. That’s why during mint some NFTs cost triple their mint price, and why people go after White List spots. White lists ensure a non-congested time for minting.
Make sure not to set your gas limit too low or else you will get an error saying “ Transaction ran out of gas”. This means that the transaction ended up using more gas than the limit you allowed and paid for. In this case, you will never be refunded the money you spent. Obviously, because the validator used valuable computational power to try and execute your transaction. It doesn’t matter if the transaction worked or not, computational power was used and you have to pay for it.
Should I Always Set the Gas Limit High?
Always setting a high gas limit is not the solution to guarantee your transaction doesn’t run out of gas. Some could argue that you can do that since the network will refund you the extra money not used. But this requires you to pay a lot of Ether upfront. It may take time to be refunded the amount of Ether not used in the transaction, which you might need. Also, the refund process requires work from validators, so why congest the system for refunds? It’s a matter of optimization, to be honest.
Usually, gas limits are set manually by your wallet handler like Metamask. You can just choose to change the gas price to pay, which you can check at ETH gas station. You are offered three price options, the more you choose to pay the faster your transaction will go. So unless there is a hyped mint or very important money transfer you need to do, don’t play with the gas limit. If you’re curious about how the blockchain works, we got this ultimate blockchain guide prepared for you!