Gas is the unit of measure for how much computational work is required to process transactions and smart contracts on the Ethereum Virtual Machine (EVM). More complex smart contracts, and code, will require more gas to execute, in the same way that a bigger, more powerful car takes more gas to run.
Calculating gas used to be very complicated, but as of the implementation of Ethereum Improvement Protocol (EIP) 1559 on August 5, 2021, it was greatly simplified. Essentially, you pay a base fee for every unit of gas, which is burned, or disappears, upon successful completion of the transaction. On top of the base fee, you add a priority fee, again per unit of gas, the value of which depends on how quickly you want the transaction to go through.
Here are some essential details for dealing with gas in MetaMask:
The gas limit
The gas limit is the maximum number of units of gas you are willing to pay for in order to carry out a transaction or EVM operation. Remember, a normal transaction sending ETH or a token normally costs 21,000 gas.
The max priority fee
The max priority fee, also referred to as the "miner tip", goes to the miner or validator, and incentivizes them to prioritize your transaction. Most often, the value you put in for "max priority fee" will be the amount you pay.
The max fee
The max fee is the total, global amount paid for your transaction. It is calculated as: (base fee + priority fee) x units of gas used. MetaMask initially sets this amount based on the previous block’s history. However, users can edit this amount through the advanced settings (see below). The difference between max fee per gas and base fee + max priority fee per gas is “refunded” to the user.
Gwei is a unit of ether, the smallest denomination, which stands for gigawei (or 1,000,000,000). Gwei is used for gas fees, or rather payments made by users to compensate for the computing energy required to process and validate transactions on the Ethereum blockchain.
Slippage is the expected percentage difference between a quoted and an executed price.
Gas fee refers to the transaction fee on the Ethereum blockchain. It is what users pay to get their transaction validated, or completed.
Generated by the protocol. Represents the minimum 'gasUsed' multiplier required for a transaction to be included in a block (i.e. for a transaction to be completed). This is the part of the transaction fee that is burnt.
Advanced Gas Controls
If you want to get into the nitty-gritty of your gas controls (this can be helpful if you're testing a dapp, for example), MetaMask can do that! See the full article here.