Gas is the unit of measure for how much computational work is required to process transactions and smart contracts. Essentially a transaction fee, the term originates from Ethereum, in which context it refers to computation undertaken on the Ethereum Virtual Machine (EVM). Since Ethereum was founded, numerous EVM-compatible (and non-EVM-compatible!) networks have emerged and adopted similar models.
The term can be considered analogous to the gas that powers a car engine: it's the fluctuating, occasionally expensive cost of operation. More complex smart contracts require more gas to power their computation, just as a bigger, more powerful car takes more gas to run.
The method for calculating gas fees varies depending on the network. For example, calculating gas on Ethereum used to be very complicated, but was considerably simplified with the implementation of Ethereum Improvement Protocol (EIP) 1559 in August 2021 (also known as the London Upgrade, following the Ethereum convention of naming major upgrades after places that have hosted its conferences). 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.
Across the broad range of EVM-compatible networks available, gas, or similarly-functioning alternatives, have essentially become the standard method of calculating transaction costs. Fees are paid in the network's native token: for example, any transaction on Ethereum requires ETH; using BSC requires BNB; using Polygon requires MATIC. Some networks have adopted Ethereum's EIP-1559 model wholesale, such as Polygon, whilst others have made adjustments, including Avalanche, for their C-Chain (which burns both the base fee and priority fee, rather than just the former).
If you want to read a more in-depth look at how gas works on Ethereum, see here.
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. Many networks, such as EVM-compatible blockchain Harmony, use an identical model in which standard transactions also cost 21,000 gas.
The priority fee
The priority fee, also referred to as the "miner tip", incentivizes the miner to prioritize your transaction.
Naturally, whether this does actually go to a miner depends on the consensus mechanism they use: Ethereum mainnet currently relies on miners as part of a proof-of-work system, whereas other blockchains, such as BSC, may be proof-of-stake. In such cases, the recipients of the "tip" are validators, rather than miners.
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 custom 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.
Other networks also tend to calculate costs using gwei -- for example, Fantom, Harmony and Avalanche.
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.