Gas Fee
What is gas?
Gas in the Ethereum network is a crucial unit that quantifies the computational effort needed to perform specific operations. This concept plays a fundamental role in how the network functions:
Purpose of Gas: Every transaction on Ethereum consumes computational resources. To execute these transactions, resources need to be compensated. This system of charging for computation serves two main purposes:
Preventing Spam: It safeguards Ethereum against spam transactions.
Avoiding Infinite Loops: It prevents the network from getting trapped in infinite computational loops.
Calculating Gas Fees: The cost incurred for executing operations on the Ethereum network is known as a gas fee. This fee is determined by two factors:
Amount of Gas: The total gas required to execute an operation.
Gas Price: The cost per unit of gas.
Importantly, this fee is charged irrespective of the transaction's outcome, whether it is successful or fails.
How are gas fee calculated?
When you initiate a transaction on Ethereum, you have the option to set the gas amount you’re willing to pay. This acts as a bid to get your transaction included in the next block. The total gas fee is composed of two parts: the base fee and the priority fee (tip).
Base Fee: This is determined by the Ethereum protocol and is the minimum amount required for a transaction to be considered valid.
Priority Fee: Also known as a tip, this is an additional amount you can offer to make your transaction more appealing to validators for quicker inclusion.
Understanding Transaction Inclusion:
Low Offer: If your gas offer is too low, validators might deprioritize your transaction, leading to delays or non-execution.
High Offer: Overbidding can result in unnecessary expenditure of ETH.
Example Calculation: Imagine Alice needs to transfer 0.5 ETH to Bob. The transaction requires 21,000 units of gas. With a base fee of 15 gwei, Alice decides to add a priority fee (tip) of 3 gwei.
The total fee calculation would be:
Units of gas used × (base fee + priority fee) = 21,000 × (15 + 3) = 378,000 gwei (0.000378 ETH).
When Alice sends the ETH, her account will be debited 0.500378 ETH in total. Bob receives 0.5 ETH. The validator gets the priority fee of 0.000063 ETH, and the base fee of 0.000315 ETH is burned.
Last updated