Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions public/content/developers/docs/gas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ You can set the amount of gas you are willing to pay when you submit a transacti

The total gas you pay is divided into two components: the `base fee` and the `priority fee` (tip).

The `base fee` is set by the protocol - you have to pay at least this amount for your transaction to be considered valid. The `priority fee` is a tip that you add to the base fee to make your transaction attractive to validators so that they choose it for inclusion in the next block.
The `base fee` is set by the protocolyou have to pay at least this amount for your transaction to be considered valid. The `priority fee` is a tip that you add to the base fee to make your transaction attractive to validators so that they choose it for inclusion in the next block.

A transaction that only pays the `base fee` is technically valid but unlikely to be included because it offers no incentive to the validators to choose it over any other transaction. The 'correct' `priority` fee is determined by the network usage at the time you send your transaction - if there is a lot of demand then you might have to set your `priority` fee higher, but when there is less demand you can pay less.
A transaction that only pays the `base fee` is technically valid but unlikely to be included because it offers no incentive to the validators to choose it over any other transaction. The 'correct' `priority` fee is determined by the network usage at the time you send your transactionif there is a lot of demand then you might have to set your `priority` fee higher, but when there is less demand you can pay less.

For example, let's say Jordan has to pay Taylor 1 ETH. An ETH transfer requires 21,000 units of gas, and the base fee is 10 gwei. Jordan includes a tip of 2 gwei.

Expand All @@ -52,32 +52,32 @@ When Jordan sends the money, 1.000252 ETH will be deducted from Jordan's account

### Base fee {#base-fee}

Every block has a base fee which acts as a reserve price. To be eligible for inclusion in a block the offered price per gas must at least equal the base fee. The base fee is calculated independently of the current block and is instead determined by the blocks before it - making transaction fees more predictable for users. When the block is created this **base fee is "burned"**, removing it from circulation.
Every block has a base fee which acts as a reserve price. To be eligible for inclusion in a block the offered price per gas must at least equal the base fee. The base fee is calculated independently of the current block and is instead determined by the blocks before it, making transaction fees more predictable for users. When the block is created this **base fee is "burned"**, removing it from circulation.

The base fee is calculated by a formula that compares the size of the previous block (the amount of gas used for all the transactions) with the target size. The base fee will increase by a maximum of 12.5% per block if the target block size is exceeded. This exponential growth makes it economically non-viable for block size to remain high indefinitely.
The base fee is calculated by a formula that compares the size of the previous block (the amount of gas used for all the transactions) with the target size (half of the gas limit). The base fee will increase or decrease by a maximum of 12.5% per block if the target block size is above or below the target, respectively. This exponential growth makes it economically non-viable for block size to remain high indefinitely.

| Block Number | Included Gas | Fee Increase | Current Base Fee |
| ------------ | -----------: | -----------: | ---------------: |
| 1 | 15M | 0% | 100 gwei |
| 2 | 30M | 0% | 100 gwei |
| 3 | 30M | 12.5% | 112.5 gwei |
| 4 | 30M | 12.5% | 126.6 gwei |
| 5 | 30M | 12.5% | 142.4 gwei |
| 6 | 30M | 12.5% | 160.2 gwei |
| 7 | 30M | 12.5% | 180.2 gwei |
| 8 | 30M | 12.5% | 202.7 gwei |
| 1 | 18M | 0% | 100 gwei |
| 2 | 36M | 0% | 100 gwei |
| 3 | 36M | 12.5% | 112.5 gwei |
| 4 | 36M | 12.5% | 126.6 gwei |
| 5 | 36M | 12.5% | 142.4 gwei |
| 6 | 36M | 12.5% | 160.2 gwei |
| 7 | 36M | 12.5% | 180.2 gwei |
| 8 | 36M | 12.5% | 202.7 gwei |

Following the table above - to create a transaction on block number 9, a wallet will let the user know with certainty that the **maximum base fee** to be added to the next block is `current base fee * 112.5%` or `202.7 gwei * 112.5% = 228.1 gwei`.
In the table above, an example is demonstrated using 36 million as the gas limit. Following this example, to create a transaction on block number 9, a wallet will let the user know with certainty that the **maximum base fee** to be added to the next block is `current base fee * 112.5%` or `202.7 gwei * 112.5% = 228.1 gwei`.

It's also important to note it is unlikely we will see extended spikes of full blocks because of the speed at which the base fee increases preceding a full block.

| Block Number | Included Gas | Fee Increase | Current Base Fee |
| ------------ | -----------: | -----------: | ---------------: |
| 30 | 30M | 12.5% | 2705.6 gwei |
| 30 | 36M | 12.5% | 2705.6 gwei |
| ... | ... | 12.5% | ... |
| 50 | 30M | 12.5% | 28531.3 gwei |
| 50 | 36M | 12.5% | 28531.3 gwei |
| ... | ... | 12.5% | ... |
| 100 | 30M | 12.5% | 10302608.6 gwei |
| 100 | 36M | 12.5% | 10302608.6 gwei |

### Priority fee (tips) {#priority-fee}

Expand All @@ -89,7 +89,9 @@ To execute a transaction on the network, users can specify a maximum limit they

### Block size {#block-size}

Each block has a target size of 15 million gas, but the size of blocks will increase or decrease in accordance with network demand, up until the block limit of 30 million gas (2x the target block size). The protocol achieves an equilibrium block size of 15 million on average through the process of _tâtonnement_. This means if the block size is greater than the target block size, the protocol will increase the base fee for the following block. Similarly, the protocol will decrease the base fee if the block size is less than the target block size. The amount by which the base fee is adjusted is proportional to how far the current block size is from the target.
Each block has a target size of half the current gas limit, but the size of blocks will increase or decrease in accordance with network demand, up until the block limit is reached (2x the target block size). The protocol achieves an equilibrium average block size at the target through the process of _tâtonnement_. This means if the block size is greater than the target block size, the protocol will increase the base fee for the following block. Similarly, the protocol will decrease the base fee if the block size is less than the target block size.

The amount by which the base fee is adjusted is proportional to how far the current block size is from the target. This is a linear calculation from -12.5% for an empty block, 0% at the target size, up to +12.5% for a block reaching the gas limit. The gas limit can fluctuate over time based on validator signalling, as well as via network upgrades. You can [view the changes in gas limit over time here](https://eth.blockscout.com/stats/averageGasLimit?interval=threeMonths).

[More on blocks](/developers/docs/blocks/)

Expand Down Expand Up @@ -120,7 +122,7 @@ High gas fees are due to the popularity of Ethereum. If there's too much demand,

The Ethereum [scalability upgrades](/roadmap/) should ultimately address some of the gas fee issues, which will, in turn, enable the platform to process thousands of transactions per second and scale globally.

Layer 2 scaling is a primary initiative to greatly improve gas costs, user experience and scalability.
Layer 2 scaling is a primary initiative to greatly improve gas costs, user experience and scalability.

[More on layer 2 scaling](/developers/docs/scaling/#layer-2-scaling)

Expand Down