The vast majority of blockchains have one thing in common — they allow users to send and receive digital assets (including cryptocurrency coins and tokens) to one another without relying on any centralized intermediaries.
Instead, blockchains leverage a peer-to-peer network of miners and/or nodes that take on the role of executing transactions in a timely fashion, ensuring their irreversibility, and maintaining a full record of all the previous transactions that occurred on the blockchain.
In simple terms, a cryptocurrency transaction occurs when a person transfers coins or tokens to an external wallet. On many smart contract platforms, transactions don’t always involve a transfer of value, as they can instead be used to invoke smart contract functions — these are known as internal transactions.
In this lesson, we’re going to take a basic look at the general principles behind blockchain-based transactions, and examine the role that fees play in their execution.
Cryptocurrency transactions are ordered into blocks by miners (Proof-of-Work blockchains) or nodes (Proof-of-Stake blockchains). Once a transaction is added to a block, it is then considered confirmed, it can then receive additional confirmations (and become more irreversible) once it is witnessed by other nodes who then update their copy of the blockchain.
When a user submits a transaction using their wallet, what they are actually doing is broadcasting to the blockchain that they wish to transfer an amount from their address to another. Using public key cryptography, the blockchain determines whether the user has the right to spend these funds, the signature included in their transaction proves to miners that they do indeed have control over the spent funds, and the transaction can be included in the block.
Each miner on the network creates what is known as a ‘block template’ which includes a list of all the transactions they want to include in the next block. If they successfully mine the next block, then this template is used, allowing the included transactions to be finalized. The miner then gets to keep all the fees included in the now confirmed transactions. Miners continually update their template to include only unconfirmed transactions, since they generally have a very low chance of mining the next block, and must always remain up-to-date.
By requiring other nodes to confirm transactions before funds are considered spent, the blockchain can prevent double-spend attacks — which see a user spend the same funds twice. It also ensures that the blockchain cannot be manipulated by a user with a large amount of mining power, since they would need to control more than 51% of all mining power to enable double-spending.
Transaction fees pay for the amount of computational work (PoW blockchains) or processing operations (PoS blockchains) completed by nodes on the network. They are provided as rewards to the miner or node that includes them in a block — this is in addition to a separate block reward, which is usually minted for the miner.
As it stands, most miner/node revenue comes from block rewards, and transaction fees make up just a small portion of their revenue. However, for platforms that incorporate a halving schedule, transactions fees will eventually become the primary source of revenue for miners/nodes.
The vast majority of blockchains require users to pay a transaction fee when sending payments or invoking smart contracts. Depending on the platform, these transaction fees can range from extremely inexpensive to potentially cost-prohibitive for many users. They also fluctuate over time in response to network congestion.
However, one thing is usually consistent among blockchain platforms — the higher the fee (in terms of $/byte), the faster the transaction is processed. Since transaction fees essentially pay for the computational work of the miners/nodes, those with the highest fees are prioritized for the next block. And since a limited number of transactions can be included in each block, only those with a sufficiently high fee will be selected. Those with a low fee will be left in the mempool until their transaction fee is competitive, if it’s not included within a set amount of time, it can be dropped — and the user would need to resubmit it.
Transaction fees are generally measured in terms of fee per byte ($/byte), since users pay based on the size of a transaction. As such, smaller transactions generally cost less to send.
As we briefly touched on, each block can only contain a certain number of transactions (the exact number varies by blockchain based on their block size and average transaction size). Moreover, blocks are processed at a known frequency, e.g. every ~10 minutes for Bitcoin or every ~13 seconds for Ethereum.
Because of this, transactions that don’t have a competitive fee might not be included in the next block. Instead, they may be included in a later block, at such time that their fee becomes competitive. This could be minutes, hours, and potentially even days later for transactions with extremely low fees.
During periods of high congestion, transaction fees often spike, which can lead to delays for those that don’t bump up their fee to compensate. Many blockchains include a way to increase the fee after the transaction has been broadcast, including the Replace-By-Fee (RBF) system on the Bitcoin blockchain.