10 August 2020
Episode 19: Transaction Fee
In blockchains, the transaction fee is the fee paid to blockchain nodes to include the transaction in a block. Generally, the transaction fee is paid in the native cryptocurrency of the blockchain. For example, in the Bitcoin blockchain, the fee is paid in satoshis which is a smaller denomination of bitcoin.
Nodes — software and hardware. Each transaction execution and verification is consuming CPU and memory on the node. The cost to keep the node running with the optimal hardware needs to be recovered from somewhere. Hence transaction fee.
To get their transactions included in a block, the user “offers” an amount of transaction fee that he can pay for that transaction. The node then decides whether they accept that fee and include the transaction or not. This approach keeps the market open and the transaction fee is decided on the average fee being offered by the users. Some users offer high fees to get their transactions included quickly, others offer a nominal fee (close to the market average) and wait for a node to accept and pick up that transaction.
In blockchains where the size and complexity are not the same for all transactions, the transaction fee depends on the byte size of the transaction and it’s execution complexity. For example, in the Ethereum blockchain, the transactions can also be smart contract calls. Smart contract functions could be of different sizes and complexity. Hence, when a smart contract function is called, the transaction fee depends on the execution complexity of that function. In such cases, the user offers an upper limit for the transaction fee. When executing the transaction, whatever fee is used is taken by the node and the remaining is returned to the user. All of this is done using the algorithms implemented as part of the protocol.