Each block has a limit to the amount of information it can contain and different types of transactions require varying amounts of block “space” in order to be processed. Users must pay what’s known as a gas fee to miners/validators depending on the type of transaction they are attempting to execute.
Simple transfers use less gas than more complex actions, such as swaps, and are therefore cheaper. However, gas fees also depend on the current ‘gas price’ which varies according to how busy the network is. Estimates of current gas prices can be tracked here.
Gas fees are always paid in Ether (ETH); in order to make transactions, an address must contain enough ETH to pay the gas, in addition to any other cryptocurrency being used in the transaction. The fee for each transaction is many orders smaller than one whole Ether, and is referred to in terms of Gwei. One Gwei amounts to 10^(-9) Ether.
i.e. 1 Gwei = 0.000000001 Ether
A good way to think about gas is to picture it as the fuel necessary to power a transaction. When a smart contract is being published, the gas is calculated for every computational step written in the code according to its complexity. The fact that every transaction on the blockchain costs something to pass, deters any potential bad actors from abusing the system by overloading it with large numbers of malicious transactions or spam.
When a transaction is submitted to the blockchain, the ‘gas limit’ can also be specified. This establishes the maximum fee that one is prepared to pay to make the transaction go through, for example, to speed up the processing time. A gas limit is also of significant advantage as it prevents the system from getting stuck in any sort of unintended loops inside smart contracts and wasting the network’s computational resources.