All about GAS – Blockchain [Part #6]

Note: This blog post is meant for beginners. If you have experience with web3 and blockchain, you might not find this as useful, but I encourage you to maybe stick around anyway.

Hello Again, You might be wondering why GAS is a separate topic of discussion. is it that important in terms of blockchain? The answer is yes it is important to understand the working of it. After this series, we’ll focus on learning about blockchain security and finding vulnerabilities. We’ll then encounter a lot of issues like gas price manipulation and gas limit exploits related to GAS fees.

What is GAS?

Think of GAS as the real fuel that powers every operation on a blockchain like Ethereum. Initially, I thought it was just a conversion fee we pay to make a transaction, but it’s more than that. Whenever we send a transaction or interact with a contract on Ethereum, we need to pay a gas fee. This fee compensates for the computing energy required to process and validate transactions.

Every action on an Ethereum blockchain costs a bit, which helps keep the network healthy and prevents spam. As you will have to pay to spam the network 😅

The price of gas fluctuates based on demand within the network during busy times.

When we make a transaction on the Ethereum network, we can set a gas limit for how much we are willing to spend, but the actual amount used can vary. If we set the gas too low, the transaction won’t go through.

Understanding Key Terms

Before we go further, let’s discuss a couple of important terms:

  • Wei: It is the smallest unit of ether.
  • Gwei: It is more commonly used unit because of its manageable size.

1,000,000,000 Wei equals 1 Gwei, and 1,000,000,000 Gwei equals 1 ether.

Understanding Our Transaction Details

Remember our first transaction? In the screenshot of our first transaction, we see a detailed breakdown:

  • Value: 0.25 ETH
  • Transaction Fee: A small amount of ETH, calculated based on the gas used and the gas price.
  • Gas Price and Limit: Set in Gwei, influencing the total transaction fee, and shows the maximum gas we’re willing to use, plus how efficiently your transaction uses its gas allowance.
  • Base and Max Fees: The base fee per gas and the maximum fee you’re willing to pay per gas unit. Part of this fee is burned, which helps reduce the overall ether supply and stabilize the market.

Breaking Down gas fees in a Transaction

Here’s what goes into a transaction:

  • Transaction Fee: Calculated by multiplying the total gas used by the gas price.
  • Gas Limit: The cap on how much gas you’re willing to use for your transaction. You can adjust this in MetaMask.
  • Base Gas Fee: A per-unit cost set in Gwei. This fee is burned to help control inflation.
  • Max Gas Fee and Priority Fee: Your ceiling for how much you’re willing to pay and a tip to miners to prioritize your transaction.
  • Block Confirmations: After your transaction is included in a block, additional blocks confirm its validity.

Setting Gas in MetaMask

When sending a transaction, you can see the Estimated fee on MetaMask

You can click on the edit icon to make changes to it. By default, you will see options like Low, Market, & Aggressive. If you need your transactions to go through fast, select Aggressive. You can see the estimated time right in front of you, and at the bottom of the screen, you can also check the network status to help you decide on a gas fee. MetaMask will even suggest if the gas fee you’ve entered is too high or too low..

Next, if you click on advanced, you’ll see fields like Max base fee and Priority fee. The Max Base Fee setting allows you to cap this amount, giving you control over the maximum you pay but still ensuring your transaction can be processed under current or slightly elevated network conditions. Adding a priority fee can help your transaction get processed faster during high traffic. Setting your gas limit too low can result in failed transactions, while setting it too high may not necessarily benefit you unless the network is particularly congested.

By understanding each component of the gas fee and learning how to adjust settings in MetaMask, we can optimize our Ethereum transactions for cost-efficiency and speed. In the next blogpost we are going to discuss about smart contracts.

Leave a Reply