Thoughts, stories and ideas.

Ethereum gas fees explained

Ethereum gas fees explained

Let's say you want to take a picture from your holidays and crop it, add some filters, whatever. You download the picture, you open it on Photoshop, you proceed, you save the image. Your machine is using computing power for all those processes.

Well, when you operate on Ethereum (sending a transaction, minting an NFT...), you are consuming power too, only you're consuming it from a swarm of computers around the world. That's what the EVM is. The Ethereum Virtual Machine is like an operative system running simultaneously on thousands of machines that anybody can access to execute the programs available on Ethereum, like using a DeFi protocol or buying an NTF. Only, instead of speaking of programs, we talk of smart contracts. And when you execute a smart contract on the Ethereum Virtual Machine, you are consuming computer power for that, just like you do with your computer at home. And just like you do with your computer at home, you pay for that. That is the reason behind gas fees.

If you've done (or attempted) a transaction on Ethereum lately, you've probably had to stop for a moment to decide whether the transaction was worth the fee you were going to pay. So for those of you who still don't understand where these fees come from and why and how they vary so much, here's our explanation. And, as always, we will be using a metaphor.

In a beautiful mountain location, travelers use a cable car to go from point A to Point B. The cable car is operated by a machinist, who stands in front of the entrance. And, in front of that entrance, people form a queue.

Now, cable cars are, well, cars suspended on a cable. They can't carry an infinite amount of weight. There is a limit, and the machinist knows this. For each car, he needs to decide how many people will fit, depending on whether they travel alone or in groups, they carry heavy luggage or nothing at all. In this peculiar mountain place, passengers will pay depending on that weight. Let's say it's $1 per kg (weird combination of dollars and kilograms, but this is crypto, we're global). The petite old lady with the bird will pay less than the backpacker carrying all his belongings.

Also, the old lady with the bird, or any other traveler for that matter, will pay more now than what they would've spent a few hours before when the queue was less crowded. As the line gets longer and the demand for a place in the car increases, the machinist might decide to increase the amount he charges per kilogram.

There's one more thing to take into account. Not all people are in the same hurry. For example, Old-lady-with-bird is going to visit her granddaughter. And it's ok if she catches the next cable car, but it's ok if she hops on the next one too. She doesn't mind. But for Executive-with-suitcase, getting on this car is vital because he's late for a meeting. So he will wave some dollar bills in the air offering a tip.

Both the ticket fees per weight and the tips end up in the machinist's pocket. And that is why he will try to optimize the space in the car to increase his revenue. He will try to fit as many people with as much luggage as possible. The heavier, the better. And if you have a tip for him, you skip the line.

Some things in this story probably feel weird. Queues don't work like this. In queues, the order is sacrosanct. It's first-come, first-serve. And the tip the executive is paying to move ahead of the old lady sounds unfair. But remember, this was a metaphor, and what's behind is a blockchain. The machinist, you've probably guessed it, is the miner. Miners are the actors in the blockchain game who manage and validate transactions and secure the network. Cashing in the fees and tips is the way users pay for their invaluable contribution.*

Each cable car in our story was a block in a blockchain. And the weight is the computing power every block can manage. That computing power in the Ethereum blockchain is called gas, and the amount of gas a block can handle is limited. So that is why people have to pay for it.

Also, not all operations on the Ethereum EVM involve the same amount of gas. For example, checking your balance costs a certain amount, sending a transaction costs some more, minting and NFT costs even more... The weight and luggage of passengers represent that. Each of them pays differently because they require a different amount of resources from the block.

The tip offered by the executive is precisely the same thing on Ethereum; a tip. Any user can add an extra to the amount they are willing to pay a miner to add their transaction earlier if they are in a hurry and want to make sure their operation gets on a block.

*Bear in mind that this is a generic description of how gas fees work and is not factoring in EIP-1559. I wish I'd had this metaphor handy when I wrote about EIP-1559 because it would've probably made my life easier... But, long story short, our dear machinist, after EIP-1559, stopped bagging the ticket fee and now mainly makes money from tips.

The Ethereum blockchain is currently going through a peak in block space demand. The queue is long and crowded. The price in $/kg is high now, and tips are flying. And last but not least, fees on the Ethereum blockchain are not paid in dollars but ETH. Therefore, if ETH increases its price relative to the dollar, an identical transaction can be more expensive in two different moments in time.

Hopefully, you now understand a little better how gas fees work. Whenever you see your wallet suggesting three different possible fees, their software factored in all these variables. They know about the block usage (=length of the queue), they know about the gas cost of your transaction (=weight), and they suggest fee prices with increasing amounts in tips.

Did you like the cable car metaphor? It can be a good starting point for further explanations about other concepts such as scalability, sidechains. I might come back to it later.