Gas and fees in Ethereum
How to pay transactions in Ethereum
Last updated
Was this helpful?
How to pay transactions in Ethereum
Last updated
Was this helpful?
you can view the blockchain Ethereum as a large virtual machine called Ethereum Virtual Machine (EVM) that executes functions from programs called smart contracts in exchange for some fees paid in ETH. Miners compete to become the executors of these transactions, and hence to receive their fees
the fee you pay to operate on Ethereum depends on 3 factors:
the computational complexity of your operation
the priority (validation speed) you set for your transaction
the usage of the network at the time the transaction is validated (inserted in a block)
gas is a unit of computational cost of a basic operation on the EVM
the term is analogous to the gas that powers a car engine: it's the fluctuating, occasionally expensive cost of operation. More complex operations require more gas to power their computation, just as a bigger, more powerful car takes more gas to run
the gas price is the price per unit of gas. It is expressed in gwei. The smallest unit of ether is the wei: wei make 1ETH. A gwei is wei, hence gwei make 1ETH
for instance, if your transaction uses 20000 units of gas and the gas price is 50 gwei, then the transaction fees are:
since the implementation of Ethereum Improvement Protocol (EIP) 1559 in August 2021, the gas price is determined by two components: a base fee and a priority fee
the base fee is set by the protocol - you have to pay at least this amount for your transaction to be considered valid (it acts as a reserve price). You pay a base fee for every unit of gas. The base fee is burned (read: it is destroyed) upon successful completion of the transaction, decreasing the supply of ETH
burning the base fee creates an interesting feedback loop between the network usage and the ETH supply. More network activity = more ETH burnt = less ETH available to be sold on the market, making the already existing ETH more valuable. In short, the more the chain is used, the more valuable it becomes. In theory, the fee burning mechanism can make ETH deflationary. This would be possible if the block reward is lower than the base fee burnt.
on top of the base fee, you might add a priority fee (or miner tip), again per unit of gas, the value of which depends on how quickly you want the transaction to go through. The priority fee goes to the validators of the blocks as an additional compensation for their work (besides the block reward)
notice that the gas price depends on the network usage at the time the transaction is validated (inserted in a block): the higher the network usage, the higher the gas price. Since the validation timestamp follows the submission timestamp for the transaction, the gas price can only be estimated when you submit a transaction
however, users can specify a max fee they are willing to pay for their transaction to be executed, which must exceed the sum of the base fee and the priority fee
moreover, users can also specify the gas limit, which is the maximum number of units of gas they are willing to pay for in order to carry out a transaction. If a transaction uses up all the gas units specified in the limit during execution, it will be automatically reverted, and any changes made to the state of the system will be discarded
you can track the gas price using this
read more about