Public blockchains are open networks that anyone with an internet connection can access. In order to control activity on them, a fee is charged using cryptocurrency for operations on the blockchain.
Gas is a measure of how much it costs someone to transact on the blockchain. This cost is defined using the gas limit, which is the cost per unit of computation the user is willing to pay, and the gas price which is the cost per unit of computation they are willing to pay.
On Ethereum, the gas price is defined in terms of the Ether cryptocurrency, and the gas limit is based on how complex the sequence of operations is. For instance, transferring cryptocurrency from one address to another is a cheap operation, whereas deploying a new smart contract can be very expensive.
Gas ensures that users can prioritise their transactions based on the gas price they are willing to pay. It also ensures that there is a real cost to trying to disrupt the network by spamming it with transactions. This helps ensure we don’t end up in a situation as we have with email where spam email is incredibly common as the cost to send it is minimal for spammers.
The gas mechanics of Ethereum are complex. The network needs to ensure that it operates a fair market for its users and that gas fees for transactions are distributed fairly among the nodes validating the network. It also needs to minimise activities such as front-running and fee manipulation by node operators. It’s also unnecessary to get into the details of this if you’re interested primarily in activity taking place on-chain.
Private and permissioned blockchain networks typically use gas to control access to the network in a similar manner to public networks. However, as access to these networks is restricted either physically in the case of private networks, or by restricting access to the currency of public permissioned networks, gas restrictions are not always necessary in these cases.
In the Chainlens Blockchain Explorer, it is possible to see the gas associated with transactions. This can be viewed in the additional details view of a transaction.
Summary
Gas is used to control access to blockchain networks.
The gas limit defines the total cost computationally associated with a transaction. The gas price defines the price per unit of computation a participant is willing to pay.
Gas is priced in Ether on Ethereum. Private and public permissioned networks do not have to have gas, but they usually do.