Most blockchains use some form of fee market to calculate transaction fees. When a large number of people want to use the blockchain, the fees go up. Fees become more expensive as the demand for block space increases. The amount of fees cannot be predicted in advance and may change. Fees are heavily affected by network congestion, which is not ideal. Cardano does not have this commonly used mechanism. Transaction fees are fixed and predictable. We will explain to you how the amount of fees for transactions and Plutus scripts is calculated. We will also explain how Cardano behaves when it is overloaded and the planned improvement called tiered pricing.
It Is Necessary To Pay For Computing Resources
It is expensive to process a transaction or execute a smart contract in a distributed network. For this to be possible, many computers must be running around the world providing their resources to the network. Running nodes is not free. People who operate nodes expect compensation from the network in the form of regular rewards.
Before a transaction gets into a block, it must be diffused throughout the network. It consumes the computing power of the nodes that must validate the transaction. The transaction is temporarily stored in the mem-pool (temporary memory). After it is inserted into the block, it will be permanently stored in the blockchain. This consumes disk space. With each new block added, the size of the blockchain grows.
Blockchain is a service for which users must pay. There is no third party subsidizing the operation of the network and making money from user data or advertising. In every decentralized network, there must be some mechanism that pays rewards to producers of blocks. User fees are a source of income for the network.
Fees For Regular Transaction
Calculating fees for a regular transaction is very simple. The calculation is based on two parameters and the size of the transaction. The formula looks like this:
Fee = A + B * size(TX)
A and B are protocol parameters that can be adjusted. Size(tx) is the transaction size in bytes.
The parameter A reflects the fixed cost of processing any transaction, regardless of its size or complexity. This serves as protection against DDOS attacks (Distributed Denial of Service).
The parameter B reflects the variable cost of processing a transaction, depending on its size. The larger the transaction, the more resources are needed to store and process it.
The protocol parameters A and B are currently set at 0.155381 ADA and 0.000043946 ADA/byte, respectively.
A regular transaction can have a size of 200 bytes. In this case, the calculation looks like this:
A = 0.155381 ADA
B = 0.000043946 * 200 = 0.0087892 ADA
Fee = 0.155381 + 0.0087892 = 0.164271 ADA
For a 200-byte transaction, the user always pays exactly 0.164271 ADA. Never more or less. The calculation is always the same.
If the transaction size were 300 bytes, it would be more expensive. The fee would be 0.1685648 ADA.
Only the size of the transaction affects the amount of fees. In the context of the UTxO model, this means that a transaction can have multiple input UTxOs and multiple output UTxOs. The more UTxOs, the bigger the size in bytes.
The most common transaction has one (or two) input UTxOs and two output UTxOs (one recipient + return of part of the sent amount back to the sender).
Remember that sending tokens and NFTs, or using metadata, increases the size of the transaction and, thus the fee.
It is possible that parameters A or B will change in the future, or the fee calculation system will change completely. The goal is for users to pay a fair fee for the service provided by the distributed network.
It is necessary to realize that non-determinism is introduced into fee systems by the volatility of the coins in which the fees are paid. Although fees are stable and deterministic in ADA value, they fluctuate in dollar value. That's not ideal. It would be most user-friendly to calculate the fee in dollar terms, as this would bring the greatest degree of stability to the system.
At the time of writing, users pay approximately 0.07 USD for a regular transaction (0.17 ADA). However, if the market value of ADA were to increase 10x in a bull market, the fee would also be 10x higher, which would be 0.70 USD (still only 0.17 ADA).
Fees For Validating Plutus Scripts
If the transaction requires Plutus script validation, the calculation of the fee depends on several factors. In addition to the size of the transaction in bytes, the number of computation (CPU) steps and the number of memory units must be taken into account during the calculation.
Transactions with scripts are usually significantly larger, as more data must be processed.
Each CPU step represents 1 picosecond of execution time. Typical scripts should consume less than 1,000,000,000 CPU units (1 millisecond).
The number of memory units represents the number of bytes that the script allocates. Typical scripts should consume less than 1,000,000 memory units (1MB of memory allocation).
Note: For regular transactions, the number of CPU steps and the number of memory units are not taken into account during the calculation of fees. They are set to 0.
The Plutus fee estimator can be used to calculate the script validation fee. The estimator can be used to calculate fees for script transactions or complete DApps before or during development.
Primitive Plutus operations are evaluated on a reference architecture to give the costs for each primitive in terms of the basic CPU and memory units that it uses. These are scaled based on the number of each different primitive that is used by a script, and overall costs for a script are calculated based on the current costs for each CPU and memory unit, plus the size of the transaction. It includes the size of the script, plus any dates that the script needs.
In the following table, you will find several examples of scripts and the calculated fees for their validation.
The maximum possible cost for a single script would be 2.17 ADA.
Using the application may require the validation of multiple scripts, so the total fee may be higher.
No Fee Market
The Cardano network does not implement transaction prioritization. Transactions are executed on a first-come-first-served basis.
Therefore, if the network touched its maximum capacity, transactions would have queued up in the mem-pool. However, the mem-pool also has a limited capacity. If the mem-pool becomes full, the network applies a back-pressure mechanism. In this case, the network does not accept submitted transactions. Users must try to submit the transaction again at a later time.
Users cannot pay extra to have their transactions processed earlier if the Cardano network is congested.
In the Bitcoin and Ethereum network, users can set a higher fee than the current level and thus essentially prioritize transactions. Block producers choose transactions based on how high the fees are. They try to maximize their profit, so they choose the transactions with the highest fees.
On the one hand, the market fee is a natural market mechanism to respond to increased demand for block space. However, on the other hand, it makes the network unreliable and exclusive (preferring the rich). Users whose transactions were skipped have to wait a longer time for settlement (hours or even days), or they have to pay more for the transaction.
However, for some use cases, it is necessary to be able to prioritize transactions.
The IOG team plans to introduce so-called tiered pricing.
The tiered pricing paper proposes splitting block space into tiers. Each tier will have a different settlement delay and fee. The number of tiers, along with delays and fees in each tier, will be adjusted automatically depending on current demand.
You can think of the mechanism as a multi-lane highway. Each lane will have different speeds and different fee charges. The right lane will be slow and fees will be cheap while the left lane will be fast but expensive. There may be multiple lanes between the left and right lanes. Users can decide which lane to take based on how fast they need to get to their destination and how much they are willing to pay.
Fees are collected in a virtual pot during an epoch and distributed through a staking mechanism between the transitions between epochs. 0.3% of ADA coins from the reserve are added to the virtual pot. In a virtual pot, there are fees along with coins from the reserve. 20% of ADA coins from the virtual pot is put into the project treasury. The rest is used for staking rewards.
A blockchain network can process a large number of cheap transactions, making it inclusive and useful. Or it may process a small number of very expensive transactions, making it exclusive and unusable. In both cases, the network can have the same fee income. It is ideal if the network scales well, as no fee market is necessary and all users are satisfied.
Cardano has fixed and predictable fees in the ADA value and it can be said that it treats users fairly. However, it still lacks a prioritization mechanism. If the network is overloaded, it is not possible to prioritize a transaction that must be settled by a specific date and time in the context of a financial service. With the approaching bull market, it would be nice to have tiered pricing in place.