Difference between revisions of "Gas fees"

Jump to navigation Jump to search
4 bytes added ,  15:33, 24 April 2022
Line 9: Line 9:
Since in a blockchain each node must independently execute every transaction, it is important to limit the amount of computational effort required from the nodes.
Since in a blockchain each node must independently execute every transaction, it is important to limit the amount of computational effort required from the nodes.
In EVM-based blockchains each transaction has a gas cost, which is defined by its complexity and its needs for storage.
In EVM-based blockchains each transaction has a gas cost, which is defined by its complexity and its needs for storage.
Each transaction has a minimum gas cost of 21.000 gas, to which is added more as the transaction gets more complicated.
Each transaction has a minimum gas cost of 21.000 gas, to which more is added as the transaction gets more complicated.
For example a swap on [[Uniswap]] costs about 190.000 gas, an [[ERC20]] token transfer costs about 65.000 gas, adding liquidity in a Uniswap v3 pool costs about 220.000 gas.
For example, a swap on [[Uniswap]] costs about 190.000 gas, an [[ERC20]] token transfer costs about 65.000 gas, adding liquidity in a Uniswap v3 pool costs about 220.000 gas.
When sending out a transaction, the user (or more commonly the wallet) sets a '''gas limit''', which is the maximum amount of gas that transaction is allowed to spend. If the transaction ends up spending less gas, the user gets a refund; if it ends up needing more gas, the transaction is automatically reverted and the gas is '''not refunded'''
When sending out a transaction, the user (or more commonly the wallet) sets a '''gas limit''', which is the maximum amount of gas the transaction is allowed to spend. If the transaction ends up spending less gas, the user gets a '''refund'''; if it ends up needing more gas, the transaction is reverted and the gas is '''not refunded.'''


== Gas price ==
== Gas price ==
To decouple the cost of transacting on the blockchain from the price of the native token, gas has its own price market dependent on the demand for transacting on the chain. The more people (or bots) want to have their transaction included, the more gas price will rise.
To decouple the cost of transacting on the blockchain from the price of the native token, gas has its own price market dependent on the demand for transacting on the chain. The more people (or bots) want to have their transaction included in a block, the more gas price will rise.
The rise is due to block producers (miners or validators) preferring transaction with higher gas prices, since they get a cut of the fee. It works exactly like an auction, so who is willing to pay more gets to have their transaction included first.
The rise is due to block producers (miners or validators) preferring transaction with higher gas prices, since they get a cut of the fee. It works exactly like an auction, so who is willing to pay more gets to have their transaction included first.
On the [[Ethereum]] blockchain gas price is measured in gwei, which is 10<sup>-9</sup> ether.  
On the [[Ethereum]] blockchain gas price is measured in gwei, which is 10<sup>-9</sup> ether.  
66

edits

Navigation menu