Understanding Ethereum Gas
Gas in Ethereum is a unit of measurement for computational power on the Ethereum network. Every transaction, whether sending tokens or interacting with a smart contract requires some gas.
Making a transaction requires computing power by a node in the Ethereum network. Gas is how users pay for that computational power. Gas does not have its own token, it is paid for in Ether. The gas can also be thought of as a transaction fee.
This spreadsheet breaks down the gas used in different types of computations. For example, a multiplication of two numbers costs 5 gas, while subtraction costs 3 gas.
Gas price is the amount of Ether the user will pay per unit of gas. The price is typically denominated in Gwei, which is a small amount of Ether, similar to cents and dollars. Gwei is one billionth of an Ether.
ETH Gas Station provides key stats about gas. Over the last 1,500 blocks, the median gas price is 7 Gwei.
The gas limit is the maximum amount of gas the user is willing to pay for the transaction. A simple transaction like sending Ether from one person to another costs 21,000 gas.
If there is any leftover gas, meaning the transactions did not require the whole gas limit, the leftover is returned to the user that sent the transaction.
To calculate the transaction fee, multiply the gas price by the gas limit. Current transaction fees are just a few cents when converted to USD.