To understand the concept of Ethereum gas, you first need to look at the protocol as a virtual machine on top of a decentralized network. The Ethereum Virtual Machine (EVM) is a decentralized platform that stores data and executes program code as a centralized computer server would.

Programs that run on top of Ethereum are called decentralized applications (dapps) for the reason that the virtual machine is built on top of a decentralized peer-to-peer network.

Gas is the unit for measuring the effort the network puts into executing decentralized application processes. Think of it as a metering unit whose payment is made in ether, the native currency of the Ethereum platform.

Why dapps

The blockchain offers dapps several advantages that old centralized servers lack. While data in servers can be changed either through official processes or system compromise, what is stored on the blockchain becomes immutable—it can never be changed except through predetermined and predefined manners.

The Ethereum blockchain also supports immutable smart contracts, which are agreements between parties written in code that self-execute without the need for arbiters when set conditions are met.

And given that the virtual machine runs on a peer-to-peer network that covers the entire globe, the risk of single points of failure is low. For the same reason, downtimes are also almost impossible.

Gas consumption

The protocol assigns gas requirements to specific types of code executions. Several executions that complete a given process form a transaction. A person launching an application on Ethereum must estimate and provide enough gas or pay for the units needed to see a transaction completed.

If the amount of gas provided is less than what is required, the system consumes it, fails to complete the transaction and returns the application to its initial state. When the gas provided is more than needed, the system consumes only what it needs and returns the balance in the form of ether—which must be used to purchase gas—to the launcher of the operation.

The network doesn’t refund gas when it receives less than the necessary amount because even if the transaction is not completed, the network has consumed electricity in the attempt and miners should be compensated for that.

The price of Ethereum gas

Gas is not a token, but rather a metering mechanism of the effort the network puts into executing code. What you get when you acquire gas is the quantification of the work involved in executing your application transactions.

The minimum or default price you pay for each unit of gas is 0.000002 ether. You can pay whatever price you want. Paying more than the default price pays miners higher transaction fees for executing your application. And the higher the price you pay for a unit of gas, the faster the network processes your transactions and adds them to the blockchain.

The functions of gas

The first purpose of gas is to incentivize miners to provide their computer power to support the decentralized network behind the Ethereum virtual machine. If miners have nothing to gain, they will have no reason to provide their computers to the network.

Because they receive rewards in the form of transaction fees, they can not only afford to keep the machines running by paying the necessary electricity bills, they are also able to profit.

The second purpose of the gas fee is to protect the system from spamming attacks. If users incur no cost to run programs and smart contracts on the virtual machine, the system is likely to be bogged down with meaningless and valueless operations.

Any person or developer is welcome to run an application or smart contract on top of the Ethereum virtual machine. But they must be prepared to pay gas for each execution the machine performs to make their application operational.