Gas

From CryptoCurrency Wiki

Revision as of 13:23, 6 June 2022 by Oscarius (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Basics

Gas in Ethereum

"Gas is the internal pricing for running a transaction or contract in Ethereum. It's to decouple the unit of Ether (ETH) and its market value from the unit to measure computational use (Gas). Thus, a miner can decide to increase or decrease the use of gas according to its needs, while if need be, the price of gas can be increased or decreased accordingly, avoiding a situation in which an increase in the price of ETH would cause the need to change all gas prices. This is also a response to the discussion in bitcoin about fees structure. If there is not enough Ether in the account to perform the transaction or message then it is considered invalid. The idea is to stop denial of service attacks from infinite loops, encourage efficiency in the code – and to make an attacker pay for the resources they use, from bandwidth through to CPU calculations through to storage.

The more complex the commands you wish to execute, the more gas (and Ether) you have to pay. For example if A wants to send B 1 Ether unit – there would be a total cost of 1.00001 Ether to be paid by A. However if A wanted to form a contract with B depending on the future price of Ether, there would be more lines of code executable and more of an onus or energy consumption placed on the distributed Ether network – and therefore A would have to pay more than the 1 Gas done in the transaction."

  • From this blog by 0x (17-9-2020):

"Ethereum transactions have different sizes measured in gas. Transactions are collected in blocks which are created about every 13 seconds. Each block has room for a limited amount of transactions, known as the gas limit. Right now, each block has room for about 12 million gas worth of transactions. A plain ERC-20 token transfer takes about fifty thousand gas. This means blocks can contain at most 240 token transfers, or about 18 transactions per second. DeFi transactions often involve multiple token transfers and other bookkeeping which multiplies the cost and further limits the throughput. The gas limit and block time mean there is a constant supply of gas available for transactions.

Each day about six thousand blocks are mined, creating room for a few billion gas worth of transactions. This amount has been changing and growing over time, mostly due to increases in the gas limit. Meanwhile, the total gas consumed by transactions has also been growing as Ethereum get more and larger transactions."