ethereum-foundation.net Open in urlscan Pro
2a06:98c1:3120::3  Public Scan

Submitted URL: https://ethereum-foundation.net/
Effective URL: https://ethereum-foundation.net/root/
Submission: On June 04 via api from US — Scanned from NL

Form analysis 0 forms found in the DOM

Text Content

Skip to main content


HELP UPDATE THIS PAGE

There’s a new version of this page but it’s only in English right now. Help us
translate the latest version.

Translate page
See English


NO BUGS HERE!

This page is not being translated. We've intentionally left this page in English
for now.

Don't show again
   
 * Use Ethereum
 * Learn
 * Developers
 * Enterprise
 * Community

Languages EN




GAS AND FEES

Last edit: , Invalid DateTime

See contributors

Gas is essential to the Ethereum network. It is the fuel that allows it to
operate, in the same way that a car needs gasoline to run.


PREREQUISITES

To better understand this page, we recommend you first read up on transactions
and the EVM.


WHAT IS GAS?

Gas refers to the unit that measures the amount of computational effort required
to execute specific operations on the Ethereum network.

Since each Ethereum transaction requires computational resources to execute,
each transaction requires a fee. Gas refers to the fee required to execute a
transaction on Ethereum, regardless of transaction success or failure.

(opens in a new tab)↗ Diagram adapted from Ethereum EVM illustrated(opens in a
new tab)↗

Gas fees are paid in Ethereum's native currency, ether (ETH). Gas prices are
denoted in gwei, which itself is a denomination of ETH - each gwei is equal to
0.000000001 ETH (10-9 ETH). For example, instead of saying that your gas costs
0.000000001 ether, you can say your gas costs 1 gwei. The word 'gwei' itself
means 'giga-wei', and it is equal to 1,000,000,000 wei. Wei itself (named after
Wei Dai(opens in a new tab)↗, creator of b-money(opens in a new tab)↗) is the
smallest unit of ETH.


PRIOR TO THE LONDON UPGRADE

The way transaction fees on the Ethereum network were calculated changed with
the London Upgrade of August 2021. Here is a recap of how things used to work:

Let's say Alice had to pay Bob 1 ETH. In the transaction, the gas limit is
21,000 units, and the gas price is 200 gwei.

Total fee would have been: Gas units (limit) * Gas price per unit i.e 21,000 *
200 = 4,200,000 gwei or 0.0042 ETH


AFTER THE LONDON UPGRADE

Let's say Jordan has to pay Taylor 1 ETH. In the transaction, the gas limit is
21,000 units and the base fee is 10 gwei. Jordan includes a tip of 2 gwei.

The total fee would now be: units of gas used * (base fee + priority fee) where
the base fee is a value set by the protocol and the priority fee is a value set
by the user as a tip to the validator.

i.e 21,000 * (10 + 2) = 252,000 gwei or 0.000252 ETH.

When Jordan sends the money, 1.000252 ETH will be deducted from Jordan's
account. Taylor will be credited 1.0000 ETH. Validator receives the tip of
0.000042 ETH. Base fee of 0.00021 ETH is burned.

Additionally, Jordan can also set a max fee (maxFeePerGas) for the transaction.
The difference between the max fee and the actual fee is refunded to Jordan,
i.e. refund = max fee - (base fee + priority fee). Jordan can set a maximum
amount to pay for the transaction to execute and not worry about overpaying
"beyond" the base fee when the transaction is executed.


BLOCK SIZE

Before the London Upgrade, Ethereum had fixed-sized blocks. In times of high
network demand, these blocks operated at full capacity. As a result, users often
had to wait for demand to reduce to get included in a block, which led to a poor
user experience.

The London Upgrade introduced variable-sized blocks to Ethereum. 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. More on blocks.


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 mined 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.

Block NumberIncluded GasFee IncreaseCurrent Base Fee115M0%100 gwei230M0%100
gwei330M12.5%112.5 gwei430M12.5%126.6 gwei530M12.5%142.4 gwei630M12.5%160.2
gwei730M12.5%180.2 gwei830M12.5%202.7 gwei

Relative to the pre-London gas auction market, this transaction-fee-mechanism
change causes fee prediction to be more reliable. 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 * 12.5% or 202.7 gwei * 12.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 proceeding a full
block.

Block NumberIncluded GasFee IncreaseCurrent Base Fee3030M12.5%2705.6
gwei......12.5%...5030M12.5%28531.3 gwei......12.5%...10030M12.5%10302608.6 gwei


PRIORITY FEE (TIPS)

Before the London Upgrade, miners would receive the total gas fee from any
transaction included in a block.

With the new base fee getting burned, the London Upgrade introduced a priority
fee (tip) to incentivize miners to include a transaction in the block. Without
tips, miners would find it economically viable to mine empty blocks, as they
would receive the same block reward. Under normal conditions, a small tip
provides miners a minimal incentive to include a transaction. For transactions
that need to get preferentially executed ahead of other transactions in the same
block, a higher tip will be necessary to attempt to outbid competing
transactions.


MAX FEE

To execute a transaction on the network, users can specify a maximum limit they
are willing to pay for their transaction to be executed. This optional parameter
is known as the maxFeePerGas. For a transaction to be executed, the max fee must
exceed the sum of the base fee and the tip. The transaction sender is refunded
the difference between the max fee and the sum of the base fee and tip.


CALCULATING FEES

One of the main benefits of the London upgrade is improving the user's
experience when setting transaction fees. For wallets that support the upgrade,
instead of explicitly stating how much you are willing to pay to get your
transaction through, wallet providers will automatically set a recommended
transaction fee (base fee + recommended priority fee) to reduce the amount of
complexity burdened onto their users.


EIP-1559

The implementation of EIP-1559(opens in a new tab)↗ in the London Upgrade made
the transaction fee mechanism more complex than the previous gas price auction,
but it has the advantage of making gas fees more predictable, resulting in a
more efficient transaction fee market. Users can submit transactions with a
maxFeePerGas corresponding to how much they are willing to pay for the
transaction to be executed, knowing that they will not pay more than the market
price for gas (baseFeePerGas), and get any extra, minus their tip, refunded.

This video explains EIP-1559 and the benefits it brings:

If you are interested, you can read EIP-1559(opens in a new tab)↗.

Continue down the rabbit hole with these EIP-1559 Resources(opens in a new
tab)↗.


WHY DO GAS FEES EXIST?

In short, gas fees help keep the Ethereum network secure. By requiring a fee for
every computation executed on the network, we prevent bad actors from spamming
the network. In order to avoid accidental or hostile infinite loops or other
computational wastage in code, each transaction is required to set a limit to
how many computational steps of code execution it can use. The fundamental unit
of computation is "gas".

Although a transaction includes a limit, any gas not used in a transaction is
returned to the user (i.e. max fee - (base fee + tip) is returned).

(opens in a new tab)↗ Diagram adapted from Ethereum EVM illustrated(opens in a
new tab)↗


WHAT IS GAS LIMIT?

Gas limit refers to the maximum amount of gas you are willing to consume on a
transaction. More complicated transactions involving smart contracts require
more computational work, so they require a higher gas limit than a simple
payment. A standard ETH transfer requires a gas limit of 21,000 units of gas.

For example, if you put a gas limit of 50,000 for a simple ETH transfer, the EVM
would consume 21,000, and you would get back the remaining 29,000. However, if
you specify too little gas, for example, a gas limit of 20,000 for a simple ETH
transfer, the EVM will consume your 20,000 gas units attempting to fulfill the
transaction, but it will not complete. The EVM then reverts any changes, but
since the miner has already done 20k gas units worth of work, that gas is
consumed.


WHY CAN GAS FEES GET SO HIGH?

High gas fees are due to the popularity of Ethereum. Performing any operation on
Ethereum requires consuming gas, and gas space is limited per block. Fees are
used to pay for calculations, storing or manipulating data, or transferring
tokens; each consuming different amounts of "gas" units. As dapp functionality
grows more complex, the number of operations a smart contract performs also
grows, meaning each transaction takes up more space within a limited size block.
If there's too much demand, users must offer a higher tip amount to try and
outbid other users' transactions. A higher tip can make it more likely that your
transaction will get into the next block.

Gas price alone does not actually determine how much we have to pay for a
particular transaction. To calculate the transaction fee, we have to multiply
the gas used by the base gas fee, which is measured in gwei.


INITIATIVES TO REDUCE GAS COSTS

The Ethereum scalability upgrades 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. More on layer 2 scaling.


STRATEGIES FOR YOU TO REDUCE GAS COSTS

If you are looking to reduce gas costs for your transactions, you can set a tip
to indicate the priority level of your transaction. Miners will 'work on' and
execute transactions that offer a higher tip per gas, as they get to keep the
tips that you pay and will be less inclined to execute transactions with lower
tips set.

If you want to monitor gas prices, so you can send your ETH for less, you can
use many different tools such as:

   

 * Etherscan(opens in a new tab)↗ Transaction gas price estimator

 * Blocknative ETH Gas Estimator(opens in a new tab)↗ Gas estimating Chrome
   extension supporting both Type 0 legacy transactions and Type 2 EIP-1559
   transactions.

 * ETH Gas Station(opens in a new tab)↗ Consumer oriented metrics for the
   Ethereum gas market

 * Cryptoneur Gas Fees Calculator(opens in a new tab)↗ Calculate gas fees in
   your local currency for different transaction types on Mainnet, Arbitrum, and
   Polygon.


RELATED TOOLS

 * Blocknative's Gas Platform(opens in a new tab)↗ Gas estimation API powered by
   Blocknative's global mempool data platform


FURTHER READING

 * Ethereum Gas Explained(opens in a new tab)↗
 * Reducing the gas consumption of your Smart Contracts(opens in a new tab)↗
 * Proof of Stake versus Proof of Work(opens in a new tab)↗


RELATED TOPICS

 * Mining

Back to top ↑


WAS THIS ARTICLE HELPFUL?

YesNo

Previous

Opcodes

Next

Nodes and clients
Website last updated: May 19, 2023
(opens in a new tab)(opens in a new tab)(opens in a new tab)(opens in a new tab)


USE ETHEREUM

   
 * Find wallet
 * Get ETH
 * Decentralized applications (dapps)
 * Layer 2
 * Run a node
 * Stablecoins
 * Stake ETH


LEARN

 * Learn Hub
 * What is Ethereum?
 * What is ether (ETH)?
 * Ethereum wallets
 * Ethereum security and scam prevention
 * What is Web3?
 * Smart contracts
 * Ethereum energy consumption
 * Ethereum roadmap
 * Ethereum Improvement Proposals
 * History of Ethereum
 * Ethereum Whitepaper
 * Ethereum glossary
 * Ethereum governance
 * Blockchain bridges
 * Zero-knowledge proofs


DEVELOPERS

 * Get started
 * Documentation
 * Tutorials
 * Learn by coding
 * Set up local environment


ECOSYSTEM

 * Community hub
 * Ethereum Foundation
 * Ethereum Foundation Blog(opens in a new tab)↗
 * Ecosystem Support Program(opens in a new tab)↗
 * Ethereum bug bounty program
 * Ecosystem Grant Programs
 * Ethereum brand assets
 * Devcon(opens in a new tab)↗


ENTERPRISE

 * Mainnet Ethereum
 * Private Ethereum
 * Enterprise


ABOUT

 * About us
 * Jobs
 * Contributing
 * Language support
 * Privacy policy
 * Terms of use
 * Cookie policy
 * Contact(opens in a new tab)↗