What Are Gas Fees And Why Are They Important?

What are gas fees?

Gas fees are an integral part of smart contract execution. They represent computational effort by providing a service fee to use the Ethereum virtual machine’s computational resources; you can think of one unit of gas as a standardized computational power unit. Each time a smart contract is deployed and run on the EVM, gas is needed in order for the contract to execute.

The minimum computational effort made by the EVM for the easiest job (a simple transaction) is 21000 units of gas, where each unit of gas has different prices that are directly correlated to the block size.

The EVM targets a block size of 15 million units of gas, but the maximum value is 30 million. If there is a spike in the network usage and from 15 million units of gas, a block has 30 million, the network will adjust itself and increase the PRICE of 1 unit of gas. This, in turn, will increase the price of the entire smart contract deployment. An increase in price will drive the usage of the network down, which will have the opposite effect because the next blocks will be smaller (the people that deploy smart contracts will pay more, so there is an incentive to wait) and the network will readjust itself, so a decrease in the price of gas will take place secondary to the decrease of blocksize.

This variable block size system ensures that over long periods of time, the block size and gas price remain close to a constant, but can have variable peaks in size and gas prices in periods of high use, like in a bull market.

What does gas do?

Gas ensures that if someone deploys a smart contract that has an infinite loop, it can be run as many times as there is enough gas provided beforehand to the EVM, so the network would not become overburdened and stopped by many bad actors that deploy infinite loops, because the gas would be enough only for a limited number of runs.

The base fees, which represent the computational effort, are burned, so there is a decrease in the rate of obtaining new ethereum in the ecosystem. 

In order to get the EVM node incentivized to run your smart contract, there must be a priority fee, which is basically "the node's tip". Technically it can be any value you desire, but usually the wallets will auto calculate a fair value in order for your smart contract to be run and the result to be introduced in the blockchain. A higher priority fee than the majority will make your smart contract be deployed faster and the new state change happen faster than your peers that deployed their code at the same time as you.

I have mentioned earlier that the minimum gas needed for any smart contract is 21000. What happens if you chose to use 10000 gas units? Well, the smart contract will be run, but it will not be completed. The state change will not take place, and because the EVM started the process and allocated computational effort, the gas fees WILL NOT BE RETURNED.

If you have a smart contract that requires 25000 gas units and you provide 100000 gas units, you will receive the difference (75000) back after the state change took place.

Conclusion

In conclusion, gas is the reflection of the cost of computational power on ethereum. More complex smart contracts require more computational power, so higher costs.