What is gas and how does it work?
Gas is the fuel that allows the Ethereum blockchain to operate. In the same way cars need gasoline to keep on driving, users on the network need to include gas (the amount of ether required to perform transactions) in their transaction request in order to fuel the completion of the transaction and add it to the blockchain.
More specifically, the term ‘gas’ refers to the unit that measures the amount of work miners need to do in order to include transactions in a block. As a result, validating and confirming transactions on the Ethereum blockchain requires a certain amount of gas, depending on the size and type of transaction.
Miners are then paid for their work of validating transactions and adding blocks with a smaller amount of Ethereum’s currency, ether (ETH). These smaller amounts have their own term ‘gwei’ with one billion gwei equal to one ether and are determined by the gas price for the transaction. The higher the urgency of the validation request, the higher the gas price that needs to be included in the transaction.
In addition to gas fees and gwei, another term used in this process is called the ‘gas limit’. This limit refers to the maximum amount of gas (or energy) that you’re willing to spend on a transaction.
The higher the limit, the more work that needs to be done to execute the transaction. If this limit is too low, the transaction can fail or be rejected with the gas paid to complete the transaction being lost. If a transaction is processed before the gas limit is reached, the rest of the gas will be sent back to the user’s wallet.