Gas (wei)

1 Ether (ETH) is equal to 10^18 wei, which means that 1 wei is 10^-18 ETH

In Ethereum, gas is a unit of computational resources that is used to measure the cost of executing smart contracts and transactions on the Ethereum network. Gas is a critical part of the Ethereum ecosystem because it allows the network to maintain its security and performance by incentivizing efficient and effective use of computational resources.

Every operation that is performed on the Ethereum network, whether it is executing a smart contract or transferring Ether between wallets, requires a certain amount of gas. The cost of gas is paid by the sender of the transaction, and is calculated based on the complexity of the operation and the current market price of gas.

Gas is measured in a unit called "wei", which is a sub-unit of Ether (similar to how cents are a sub-unit of dollars). The price of gas is denominated in wei, and is determined by the market supply and demand for computational resources on the Ethereum network.

When a transaction is submitted to the Ethereum network, the sender specifies the maximum amount of gas that they are willing to pay for the transaction. If the gas limit is too low, the transaction may fail or be rejected by the network. If the gas limit is too high, the sender may end up paying more than necessary for the transaction.

The gas limit and gas price are important parameters for Ethereum users to consider when sending transactions on the network. By adjusting these parameters, users can control the cost and speed of their transactions, and ensure that they are able to execute their desired operations on the network.

Wei

"Wei" is the smallest unit of Ether, the cryptocurrency used on the Ethereum network.

1 Ether (ETH) is equal to 10^18 wei, which means that 1 wei is 10^-18 ETH. The wei unit is used to represent very small amounts of Ether, such as the cost of gas for executing a single operation on the Ethereum network.

The term "wei" is named after Wei Dai, a computer engineer and cryptocurrency pioneer who is best known for creating the concept of "b-money", an early precursor to Bitcoin and other cryptocurrencies.

Common use

Gwei (10^9 Wei) is the most commonly used unit of measurement for gas prices and transaction fees in Ethereum, as it allows for prices to be expressed in smaller and more manageable numbers. Ether (ETH) is the most commonly used unit of measurement for balances and transaction values, as it is the most intuitive representation of the native cryptocurrency in Ethereum. However, all of the units in the table are widely recognized and used in the Ethereum ecosystem, depending on the context and purpose.

Wei is the smallest and most basic unit of measurement in Ethereum, representing a single atomic unit of ether. While it is not commonly used for expressing balances or transaction values, it is used extensively for measuring the cost of gas and transaction fees, as well as for specifying certain parameters of smart contracts and interacting with the Ethereum Virtual Machine.

How is the gas price set?

The price of gas is not set by any centralized authority or entity, but rather determined by the market forces of supply and demand. In other words, gas prices are set by the users of the Ethereum network, who offer to pay a certain amount of ether (in Gwei or a subunit thereof) for each unit of gas required to execute their transactions or smart contracts. Miners and validators, who are responsible for processing and validating these transactions, can choose which transactions to include in the blockchain based on the offered gas price and the total amount of gas required, prioritizing transactions with higher gas prices. As such, gas prices can vary widely based on the current network congestion, user demand, and other factors.

High & Low demand

High demand for transactions on the Ethereum network can cause network congestion, as there are more transactions waiting to be processed than can fit in a single block. This can result in slower confirmation times, as miners and validators must choose which transactions to include in the block based on the gas price offered by the transaction sender. As such, users who want their transactions to be processed more quickly may need to offer a higher gas price to incentivize miners and validators to include their transactions in the next block.

On the other hand, low demand for transactions can lead to shorter confirmation times and lower gas prices, as there are fewer transactions competing for space in the blocks. In extreme cases, low demand can lead to a situation where miners are not able to fill up the block with transactions, resulting in underutilized block space.

Overall, the supply and demand dynamics of the Ethereum network can have a significant impact on gas prices and confirmation times, with higher demand typically resulting in higher gas prices and longer confirmation times, and vice versa.

Target Gas Limit & Gas Used

Each block in the Ethereum blockchain has a target gas limit and a gas used value that are recorded in the block header. The gas limit is the maximum amount of gas that can be used by all transactions included in the block, while the gas used is the total amount of gas actually consumed by those transactions.

Miners and validators are incentivized to optimize their block construction strategy to maximize the amount of gas used without exceeding the gas limit, as they can earn more transaction fees if they include transactions with higher gas costs. If the total gas used by the transactions in a block exceeds the gas limit, the block is considered invalid and will not be included in the blockchain. As such, miners and validators must strike a balance between maximizing their revenue and ensuring that the block remains valid.

The target gas limit for each block is dynamically adjusted based on the network's congestion levels, with the aim of maintaining a reasonable balance between transaction throughput and network stability. If the network becomes too congested, the gas limit may be temporarily lowered to prevent the network from becoming overwhelmed. Conversely, if the network is relatively quiet, the gas limit may be increased to allow for more transactions to be processed in each block.

The target gas limit for each block in the Ethereum network is not fixed, but is instead dynamically adjusted based on the network's congestion levels. The adjustment process is carried out by the network's consensus algorithm, which is responsible for determining which blocks are valid and should be added to the blockchain.

The consensus algorithm uses a variety of factors to determine the optimal gas limit for each block, including recent transaction volumes, historical block sizes, and network congestion levels. The algorithm aims to strike a balance between transaction throughput and network stability, ensuring that the network can process transactions efficiently without becoming overwhelmed by excessive network traffic.

While the exact details of the consensus algorithm used by Ethereum may vary depending on the implementation, most implementations rely on a variant of the proof-of-work or proof-of-stake consensus mechanisms to determine the optimal gas limit for each block. These mechanisms involve a complex series of cryptographic computations and economic incentives that are designed to encourage miners and validators to behave honestly and contribute to the network's overall security and stability.

Example

    High Demand    │  Low Demand
  ────────────────-┼────────────────
  Gas Limit: 12M   │ Gas Limit: 15M
  Gas Used: 8M     │ Gas Used: 4M
  ────────────────-┼────────────────
  Price: 60 Gwei   │ Price: 20 Gwei

In this example, we have two scenarios: high demand and low demand for transactions. In the high demand scenario, there is a lot of competition among users to have their transactions included in the blockchain. As a result, the gas limit for each block is set lower (12 million) to ensure that the network does not become overwhelmed. However, there are still many users trying to send transactions, and so the gas price rises to 60 Gwei in order to incentivize miners to include those transactions in their blocks.

In the low demand scenario, there are fewer users trying to send transactions, and so the gas limit for each block is set higher (15 million). Because there is less competition among users, the gas price is lower (20 Gwei) since miners do not need as much incentive to include those transactions in their blocks.

It's important to note that these numbers are purely illustrative, and that the actual gas limit and gas prices in the Ethereum network can vary widely depending on a variety of factors, including network congestion, transaction volumes, and miner behavior. However, the basic relationship between gas limit, gas used, and gas price remains the same regardless of these external factors.

How are miners paid?

Miners in the Ethereum network are paid in ETH for processing and validating transactions. When a user sends a transaction, they include a gas fee, which is the amount they are willing to pay to have their transaction processed by the network. This gas fee is paid in ETH and is collected by the miner who includes that transaction in their block.

In addition to the gas fee, Ethereum also introduced a new feature called the base fee as part of the EIP-1559 upgrade. The base fee is a dynamic fee that is burned (i.e., destroyed) upon inclusion in a block, rather than being paid to the miner. The base fee is set algorithmically based on network demand, and is designed to increase during periods of high congestion and decrease during periods of low congestion. The goal of the base fee is to make the cost of sending transactions more predictable and stable, while also incentivizing miners to prioritize transactions with higher gas fees.

Last updated