Easily understand Gas, Gas Limit and Gas Price on Ethereum

Wyman Fung
NEST Community
Published in
4 min readMay 24, 2020

NEST Protocol

What is Gas?

Gas is inside the Ethereum Virtual Machine (EVM) and is a unit of measurement for calculating workload . As a fuel in the Ethereum network, it provides a driving force for the development and operation of the Ethereum network ecology. Just as gasoline plays a role in cars, Gas is essential for Ethereum users and developers.

On the one hand, Gas is used as a reward for Ethereum miners to process blocks. On the other hand, its existence raises the threshold of malicious transactions and can better maintain the normal operation of the Ethereum network .

At the bottom layer of the Ethereum system, the gas consumption is determined for each prescribed operation and contract method, and each operation step in the transaction process requires gas consumption. For example, users who deploy the NEST oracle quote contract need to pay a certain Gas fee to execute this transaction, and Gas is the processing fee charged by the Ethereum system to users. When using the Ethereum network, the maximum gas consumption must be set. When the gas is consumed or the smart contract logic is executed, the execution of the contract will be stopped. In the Ethereum system, Gas needs to be converted to ETH for payment.

Tip: No matter whether the user-initiated transaction is successfully processed, you must pay the Gas fee, this is like if you drove home on the road and drove half of it without gas. Even if you did not get home, but the gasoline consumed is indeed already consumed and so we have to pay for it.

What is Gas Limit?

Gas Limit is the maximum amount of Gas that Ethereum users are willing to pay to successfully execute a certain transaction logic .

If the Gas Limit of a transaction is set too low to complete the transaction logic, the system will prompt “out of gas” and the transaction will fail. This transaction will still be recorded into the block, and the Ethereum assets carried in the transaction will be automatically returned, but the Gas fee will still be collected and the fee will be issued as a reward to the miners who processed this block. (Users who often deploy smart contracts should have encountered this situation)

If the amount of Gas used by this transaction is less than or equal to the Gas Limit you set, it will be processed successfully. The total amount of Gas actually consumed in the execution of this transaction is Gas Used, and the unused Gas will be returned to the transaction originating address .

Please note that our Gas Limit here refers to the Gas limit of a transaction. Throughout the development of Ethereum, there is also a Gas Limit value that is more important and often mentioned. That is the Gas Limit of a block, the upper limit of the total Gas that can be executed by a single Ethereum block.

When each block is processed, the total Gas Limit of all transactions in the current block will be determined to determine the number of transactions that can be processed in the block, so the miner will judge the current Gas amount when processing each transaction wethere there is sufficient of Gas amount to process the current transaction. If you process a transaction that will exceed the current block Gas Limit, it will be rejected by the Ethereum network, and the system returns with “below gas limit”. After several upgrades to Ethereum 1.x, the current Gas Limit value of an Ethereum block is 12 million Gas.

Ethereum Gas Tracker

Price of a single Gas: Gas Price

Gas Price is the price that users are willing to pay for each Gas, and the unit is Gwei .

1 ETH = 1,000,000,000 Gwei

In addition to receiving rewards for mining blocks, Ethereum miners always hope that the block contains more Gas fees. Therefore, when the mining pool processes transactions, it will give priority to process transactions that pay more miners fees .

Miner’s fee for a transaction = Gas Price * Gas Used

Therefore, the higher the Gas Price setting, the faster the transaction will be processed into the block and it will be confirmed first. If the Gas Price is set too low, the transaction will be in the pending state for a long time, waiting in line to be processed by the miner. Therefore, when the Ethereum network is congested, if we want to speed up the transaction, we need to greatly increase the Gas Price value of the transaction, so that the miner will process our transaction first.

The above is about the definition and relationship of Gas, Gas Limit and Gas Price parameters in the Ethereum network. If you want to be more directly experience for oneself of blockchain technology and smart contracts, then quickly deploy your own smart contract on the Ethereum chain, or join the NEST price oracle network, become a quote miner, and participate in oracle quotes .

Author signature: NestFans

NEST website: https://nestprotocol.org

NEST oracle docs: https://docs.nestprotocol.org

Telegram: https://t.me/nest_chat(NESTFans chat group)

Twitter: https://twitter.com/BruceYang_NEST(active NEST fan)

NEST Fans: https://nestfans.com(NESTFans chinese forum)

--

--