In this article, we'll provide a brief overview of Ethereum transactions and how to select the optimal fee.
Overview of Ethereum Transactions
Ethereum transactions are signed by Externally Owned Accounts (EOAs) and some of the data included are the gas price and the gas limit. Gas is a separate virtual currency that has its own exchange rate against ether (ETH).
For Bitcoin, transaction fees only account for the size of the transaction in terms of kiobytes. Conversely, in Ethereum, transactions can cause a smart contract to be executed in the Ethereum Virtual Machine.
Therefore, each computation step and smart contract code execution must be taken into account, where each step costs a fixed amount of gas. The Turing complete computation model needs a form of metering to avoid denial-of-service attacks or transaction that takes up too many resources.
What is Gas?
The purpose of gas is to control the resources that a transaction can use, since it will be processed on computers distributed all over the world. Gas is separate from ETH in order to protect the system from volatility in the value of ETH and as a way to manage the ratios between the costs of various resources that gas pays for (e.g., computation, memory and storage). Gas is also used to reward the miners for the work they do.
The gas price component of a transaction allows a user to set the price they are willing to pay in exchange for gas, where the price is measured in wei per gas unit. Wallets can change the gas price to achieve faster confirmations of transactions.
- The greater the gas price, the faster the transaction is likely to be confirmed.
- Lower priority transactions can use a lower gas price which means confirmation will be slower.
The gas system discourages spam transactions, as these transactions must pay for the computational, bandwidth, and storage that they consume in proportion to the gas costs for these operations. Gas only exists inside the EVM to track how much computational work is going on. For the transaction fee paid in ETH, it is exchanged into gas for EVM accounting and then back to ETH when paid to the miner who confirmed that particular transaction.
The market decides the relationship between the price of ETH and the cost of computing operations in terms of gas. The gas cost is a measure of computation and storage used in the EVM, where the the gas has a price measured in ether. When sending a transaction, you can specify the gas price you are willing to pay in ETH for each unit of gas. The transaction fee is calculated by the equation below:
transaction fee = total gas used * gas price paid (in ether)
Gas limit is another important field included in a transaction with relation to fees.
Gas limit gives the maximum number of units of gas the transaction originator is willing to buyin order to complete the transaction. For simple payments, meaning transactions that transfer ETH from one EOA to another EOA, the gas amount is fixed at 21,000 gas units. To calculate how much ETH that will cost, you multiply 21,000 by the gas price you’re willing to pay.
If your transaction’s destination address is a contract, then the amount of gas needed can be estimated but cannot be determined with accuracy. Since a contract can evaluate different conditions that lead to different execution paths, many different total gas costs arise depending on the execution path. If external factors are at play, you may not know if the contract with execute a simple or complex computation.
Estimating Ethereum Transaction Fees
There are several useful resources that can help you track gas prices and select the optimal fee for sending Ethereum transactions:
EtherFees is a basic Twitter bot created by Justin Camarena, a software engineer at Bitrefill, that publishes information on Ethereum transaction fees. Specifically, EtherFees shows the fast, average and safe low gas prices for getting your transaction confirmed, as well as the number of pending transactions.
The gas prices published by EtherFees are actually taken from ETH Gas Station, detailed below.
2. ETH Gas Station
ETH Gas Station is a popular website that provides information on the relevant gas metrics for the Ethereum network, allowing traders to determine the gas price they should use if they want to deposit funds quickly to an exchange (using the recommended gas price under ‘Trader’) or if they want to withdraw their coins to cold storage with the lowest fees (using the recommended has prices under ‘Standard’).
Applications with the most Ethereum spent and the average gas price can also be found on ETH Gas Station. If you're interacting with a popular contract, you can check the top 10 Ethereum contracts by transaction count to set appropriate gas prices.
The Tx Calculator can also help in optimising on fees. Enter some inputs for a transaction and it allows you to predict outcomes for variables like average time to confirm or the spend on transaction fees in ETH or USD.
EtherScan’s gas tracker provides a lot of useful information on gas prices and transaction confirmation times. The main hub shows the gas prices for fast, normal and slow confirmation times.
EtherScan's gas tracker also shows the histogram of the time spent in the transaction pool and the gas price for the last 1000 blocks. For instance, the histogram in the screenshot above shows that a gas price of 50 was enough for a confirmation time of less than 250 seconds on average in the last 1000 blocks.
No additional gains in terms of confirmation time were to be gained by paying more than 51 Gwei according to the chart. However, a gas price of 47 Gwei saw an average confirmation time of almost 1000 seconds.
More detailed information on the accounts and smart contracts that use the most gas are also displayed:
Ethviewer is an interactive transaction visualiser showing the number of transaction, gas prices paid and the amount of ETH in the pool, ordering transactions based on the gas prices paid and showing each transaction on the Ethereum blockchain live:
The tool was created by Australia's national science agency, CSIRO. The tool is still in beta and the 'About ethviewer.live' section notes that there are many issues with all browser types.
TxStreet, created by web developer @revofever, is another interactive website that represents each transaction as a person which eventually boards a bus. Each person leaves a particular house, which represents a decentralised application on Ethereum (e.g., Tether, Uniswap, Chainlink), and each bus represents a block to be added to the distributed ledger.
The block number and average gas price are shown on each bus for that particular block. Under Stats you can view transactions per second, the median estimated fee in US Dollars and the median gas price:
You can also follow individual transactions or obtain a detailed breakdown of each block, including metrics such as the distribution of gas prices, the estimated confirmation time and the number of transactions:
TxStreet also allows you to compare pending transactions, transaction fees, etc. between the Ethereum blockchain and Bitcoin (or Bitcoin Cash) blockchain: