# Gas Price

## <mark style="color:purple;">How are gas fees calculated and paid?</mark>

Gas fees are based on the fundamental economic concept of <mark style="color:purple;">**supply and demand**</mark><mark style="color:purple;">.</mark>&#x20;

In the case of a blockchain, supply is the total computing power of validators on the network and demand is the total computing power required to execute network users’ submitted transactions.&#x20;

Prior to Ethereum’s London Upgrade in August 2021, gas was calculated based on two factors:

* <mark style="color:purple;">**Gas price:**</mark> The price a user elects to pay for each unit of gas. You can think of it as setting the price you’re willing to pay per unit of fuel.\
  &#x20;
* <mark style="color:purple;">**Gas limit:**</mark> This is set by the user and determines the maximum amount of gas that can be used to perform a particular function. You can think of this as the maximum number of gallons of fuel a driver is willing to purchase.

Multiplying these two components together, <mark style="color:purple;">**Gas price x Gas limit**</mark> resulted in the maximum gas fee a user might pay to execute a transaction.&#x20;

After the introduction of <mark style="color:purple;">**EIP-1559**</mark>, which aims to make gas fees more predictable, gas fees are calculated based on a new formula:&#x20;

<mark style="color:purple;">**Gas limit x (Base Fee + Priority Fee (Tip))**</mark><mark style="color:purple;">.</mark>&#x20;

Rather than users determining the cost of gas fees, the Ethereum network now implements a base fee that automatically adjusts per block depending on user demand, while also outlining the lowest possible price a user must pay to have their transactions processed.

Once a gas fee is paid, the base fee amount of ETH is permanently removed (burned) from circulation. The update also allows users to tip validators (attach a priority fee) at their discretion in order to have their transactions processed quicker.

In a scenario where a user sets the gas limit too high, the network will automatically refund them the difference after their transaction has been processed.
