What is gas?
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 4, 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. A standard transaction sending ETH 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. The difference between max fee per gas and base fee + max priority fee per gas is “refunded” to the user.