Gas is like the "fuel" you need to perform any action within a blockchain like Ethereum.
If you want to send money, execute a smart contract, or use an application, you have to pay with gas for the network to do the work for you.
How does gas work?
Think of a car:
For your car to work, it needs gasoline. In a blockchain, the "car" is the network, and the "gasoline" is the gas.
Out of gas, the transaction cannot proceed.
You pay with the network's currency:
Even though we talk about gas, you pay for it with the blockchain's currency.
For example, on Ethereum, you pay for gas with ETH.
Variable costs:
The price of gas changes depending on how much traffic there is on the network.
If many people are using the network at the same time, gas is more expensive.
If the network is quiet, gas is cheaper.
Why do you need gas?
So that the "miners" (or validators) process your transaction. They use their computational power to keep the network running, and gas is their reward for that work.
Gas issues:
It can be expensive:
If there are a lot of people using the network, the price of gas goes up a lot, and a simple transaction can cost you more than you want to pay.
If you don't put enough gas:
Your transaction might fail, but the gas used up to the failure is not refunded.
A simple example:
Let's assume you want to send 1 ETH to a friend.
Gas is like the fee you pay for your transaction to be processed.
If the gas fee is low, your transaction will be slower. If you pay more gas, it will be processed faster.
Practical example:
Imagine you send 1 ETH to a friend:
Gas Limit: 21,000 units (standard for simple transfers).
Gas Price: 50 gwei.
Total gas cost = 21,000 × 50 gwei = 0.00105 ETH.
This cost is paid when processing the transaction, in addition to the 1 ETH you are sending.
In summary:
Gas is the cost of using a blockchain.
Helps the network function, prevents people from abusing it, and ensures that miners or validators are compensated.
Think of it like a toll you pay to use the road, but with a price that goes up and down depending on how many cars are on the road.