What is ether?
Ether (ETH) is the built-in currency used in the Ethereum network.
Like bitcoin (BTC), it can be seen as a digital asset used to store and/or transfer value on the blockchain.
But ether’s main use case is to facilitate the computation of smart contracts and decentralized applications (dApps) on the Ethereum network.
Anyone looking to build software on Ethereum has to pay for the computing power with ether (ETH).
An Ethereum node has to execute a transaction on the network and isn’t going to do it for free. Without ETH, you simply cannot do anything on Ethereum.
This was done by design to solve one of the biggest issues with a Turing-complete machine: the halting problem.
While a Turing-complete machine is pretty awesome in that it can process pretty much any conceivable computation you throw at it, it doesn’t know when to stop calculating if you don’t tell it to.
So, if an app is programmed to run in an infinite loop, that app will run forever. Such a scenario would cause major problems or even grind the Ethereum network to a halt!
To help disincentivize bad actors from running code with infinite loops or spamming the network with computation-heavy contracts, Ethereum imposes transaction fees (paid in ETH) in order to run smart contracts.
This requirement makes ether a key mechanism in keeping the demand for computational resources on the Ethereum network in check.
It’s pretty much like gas in a race car. Without gas, the car won’t start. And the bigger the car or harder you push the car to go, the more fuel is needed to maintain speed and reach the finish line.
If the gas runs out then the car just stops, just like an application when it runs out of ether.
What is gas?
The term “gas” was created to differentiate between the value of ether (ETH) and the computational cost of using Ethereum’s virtual machine (EVM).
Gas is how the Ethereum network measures the computational effort required to execute transactions.
It is called gas because similar to how automobiles need gasoline to operate, the Ethereum network needs gas to keep operating.
For example, sending 1 ETH from Person A to Person B may require 21,000 gas units. More complex transactions, such as minting an NFT, could demand 2,000,000 gas or higher.
This means that gas itself is not your transaction fee.
Gas is a unit used to measure the computational effort necessary to perform specific actions on Ethereum’s blockchain. The transaction fee involves other factors like base fees and priority fees.
Gas is also not ETH.
The price of 1 gas unit rises when Ethereum’s network is busy and falls during off-peak hours.
The amount of “gas” required s determined by the supply of mining capacity and the demand for transactions needed to be processed. Since miners can decline to process transactions if the gas price is too low, the gas price must be high enough to outweigh the cost of the computational power needed to process these transactions.For example, the price of 1 ETH rises when a lot of people suddenly want NFTs and falls when someone makes a controversial tweet attacking the usefulness of Ethereum.
But gas IS priced in ETH.
Gas price is the amount of ETH it takes to pay for one unit of gas.
If one unit of gas is priced at 0.000000015 ETH, your transaction requiring 21,000 units would need at least 0.000315 ETH to push through.
Whoa. That’s WAY too many decimals and so few ETH!
Others think so too.
Enter giga-wei or gwei.
Gwei represents a fraction of 1 ETH.
Like cents to a dollar, wei is the smallest denomination of ETH. Gigawei translates to 1,000,000,000 wei or 0.000000001 ETH.
There are other ways to denominate ETH, but gwei is the more commonly used among ETH users.
In the example above, instead of saying that gas price is at 0.000000015 ETH, you can just say that gas price is 15 Gwei.
That’s “gwei” more convenient!
How is the gas fee calculated?
Of course, the transaction fee doesn’t just involve gas and gas prices. It also includes the BASE FEE, which is the price required to put one gas unit on Ethereum’s block.
Base fees are determined by the blocks before it. The base fee can increase by as much as 12.5% per block if the previous block’s transactions used more gas than the target block size allotted for.
But you don’t just pay for the service. You gotta add a tip, too!
Remember that miners receive block rewards no matter what’s inside an Ethereum block.
To incentivize them to compute for your transaction and add it to the blockchain, you can add a PRIORITY FEE (or TIP) per gas unit when you input your transaction details.
And you thought Uber Eats drivers were demanding.
At this point, your minimum transaction fee would look like this:
Tx fee = (gas units the transaction requires) x (gas price at least equal to the base fee + tip)
But what if you executed an uncommon transaction that needed way more gas than you thought? You’ll end up paying waaay more than you originally thought!
This is why users usually add a gas limit to their input.
In our fuel example, budgeting for a road trip (executing a transaction) would mean thinking about the price of fuel (gas price) as well as the maximum gallons you think the road trip would need (gas limit).
“Gas Limit” is the maximum number of gas units you’re willing to pay to execute your transaction.
Using a gas limit ensures that you don’t accidentally spend way more than your budget. You’re protected from a faulty contract code suddenly requiring more gas.
Alternatively, users have the option to set a MAX FEE LIMIT to tell the network the maximum gwei you’re willing to spend on your transaction.
Don’t be too stingy with your Gas and Max Limits though! Miners will only use enough gas and gwei to run the transaction and refund you the rest.
But if a transaction hits its Gas or Max Limit and “runs out of gas” before it is executed, then the transaction will fail and you will lose the gas the miners had already consumed.
That would be…”gwei” too much waste.
Factoring in Gas Limits, our new minimum transaction fee formula would look like this:
Tx Fee = (Gas Limit) * (Base fee + Tip)
Let’s say that Person A is sending 1 ETH to Person B.
The simple transaction only requires 21,000 gas but a lot of folks are swapping ERC-20 tokens so the current base fee is 300 gwei. Person A decides to tip 20 gwei to ensure that the 2 ETH is transferred.
Using the formula above, Person A’s transaction fee is:
(21,000) x (300 + 20) = 6,720,000 gwei or 0.00672 ETH
That’s about $18.84 for transferring 1 ETH (~$3,000)!
$18.84 may still be a bit steep for some. Luckily, there are efforts to reduce transaction fees.
Ethereum’s switch to Proof-of-Stake (PoS) consensus algorithm, for example, would reduce the computational requirements per transaction.
A bunch of Layer 2 scaling solutions also promise to lighten the network load by doing the heavy computation off-chain.
Most wallets and platforms can automatically estimate the gas and gas prices for your transactions.
But if you want to practice your transaction fee computing skillz, then you’ll definitely want to check out this cheat sheet!
|Gas||Unit of measurement for the computational effort miners needs to execute your transaction and record it on Ethereum’s blockchain.|
|Block/Base Fee||The minimum amount of gas required to put the transaction on the latest Ethereum block. Base fees are “burnt” at the end of each transaction.|
|Gwei||Short for gigawei, a name for a fraction of 1 ETH you need to pay for transaction fees.
1 Gwei = 0.000000001 ETH
Ex: If you’re sending 1 ETH and your total transaction fee is 4230000 gwei (0.00423 ETH), you’ll need to send 1.00423 ETH to successfully execute your transaction.
|Gas Price||The number of gwei you’re willing to pay for one unit of gas.|
|Gas Limit||The maximum number of gas units you’re willing to pay to execute your transaction.
You can adjust how much gas you want to spend but setting a gas limit that’s lower than the total gas needed will lead to your transaction “losing gas” and failing.
Different types of transactions will require a different minimum gas amount to complete.
|Max fee||The maximum cost (in gwei) you’re willing to spend on your transaction.
After the actual fees and tip have been deducted, the remainder of the max fee will be refunded to the transaction sender.
Like in gas limits, setting a max fee lower than the actual fee needed will result in a failed transaction.
|Priority Fee/Tip||An additional fee you pay to miners to include/prioritize your transaction on the blockchain.|
|Gas burn||When users pay for their transactions, their base gas fee gets destroyed (permanently removed from circulation) by the protocol.|
|Transaction fee formula||(Gas Limit) x (Base Fee + Tip)|