Plutus fee estimator: find out the cost of transacting on Cardano
Our new fee estimator – released today – will help developers estimate the cost of smart contract scripts for maximum efficiency and minimum cost
21 January 2022 6 mins read
The ‘Alonzo’ smart contract upgrade deployed to the Cardano mainnet in September 2021 turned Cardano into a functional platform for the development of decentralized applications (DApps) built in Plutus.
With the Cardano ecosystem steadily growing, a great number of DApps are being built and readied for launch on Cardano. Either in final testing, deployment, or active development, Cardano will soon host a variety of DApps covering DeFi offerings, NFT markets, wallets, exchanges, games, and more.
The deterministic design of the Cardano ledger allows developers to predict how much they will pay for contract execution and there’s no fee for contract failure. Deterministic transaction processing, low fees, and security – all of these are major benefits of transacting and building on Cardano. Here, we’ll take a closer look at Cardano pricing and introduce a new Plutus fee estimator developed to provide better clarity on the processing fees.
The benefits of building on Cardano
Many factors influence a blockchain's price competitiveness: functionality, quality, security, and, of course, liquidity.
The design principles underpinning the Cardano ledger ensure high performance while respecting rigorous security properties. Cardano uses an Extended Unspent Transaction Output (EUTXO) accounting model, which greatly contributes to its deterministic design. Determinism refers to the predictability of outcomes. This means that Cardano transactions and scripts can be validated locally (off-chain), so letting the user know if a transaction is valid before executing it on-chain and without paying any fees. Moreover, transaction fees are fixed and predictable. To compare, smart contract execution costs on Ethereum vary depending on the network load, with fees fluctuating from $5 to hundreds of dollars (see The ridiculously high cost of Gas on Ethereum). Moreover, even failed Ethereum transactions may also incur fees, creating additional uncertainty about pricing.
In contrast, on Cardano, users can calculate the potential fees for transaction processing in advance. Because the user knows in advance whether the transaction is valid or not, there is no need to pay for a transaction that will potentially fail. This saves wasting funds and eliminates on-chain failures. Cardano’s execution fee in ada is always stable as it depends on pre-set network protocol parameters rather than on varying network congestion factors, for example.
Cardano’s pricing model relies on demand over supply
Cardano’s approach to price setting mainly relies on market demand over actual supply. With smart contract support on Cardano, there is now more than one type of demand competing for the common supply. Thus, it is crucial to consider both relative and absolute pricing. One way to do this is to inspect the effects of smart contract pricing, non-fungible token (NFT) operations, etc., with respect to some common value – in our case, the consumption of Cardano’s processing power.
With Cardano, smart contract pricing model is based on a fixed cost, which relies on the pricing of the spent resources (UTXO size or computation/memory used when running).
Fees must be paid to fairly compensate for stake pool operation (SPO) work and for the resources used to validate network transactions. In addition, making sure that any particular way of using Cardano is not substantially cheaper than another helps mitigate whole classes of adversarial attacks (e.g. a classic DDoS attack).
Flexibility is also key and an important feature of the Cardano protocol as it provides the possibility to change its parameters and adapt to price fluctuations. For example, if ada significantly increases in value, protocol parameters can, if required, be adjusted to prevent the user from overpaying for smart contract execution.
Plutus fee estimator
The Plutus fee estimator tool has been developed by IOG for price benchmarking and comparison. Today we are making it available for developers or curious Cardano users on our public testnet site. The estimator uses information from real-world Plutus transactions to predict the fees that will be charged for a transaction. The estimator can be used to calculate fees for actual transactions (e.g. to determine the fees that will be charged if the network parameters change), and also to estimate fees for individual script transactions or complete DApps before or during development. It may also be useful to determine the effect of script changes or optimizations on fees.
The estimator uses the same fee calculation formula as the actual Cardano node. Given sufficiently accurate inputs, it can give an accurate idea of the required fee. By combining the costs from multiple transactions, a user can easily predict how much a whole DApp might cost. This will be valuable for developers, business analysts, etc. The estimator includes a number of examples based on real transactions that have been verified against actual fees.
Fee calculation requires three pieces of information:
- The total on-chain transaction size in bytes: a simple transaction, for example, is around 300 bytes, one with metadata is around 650 bytes, and Plutus scripts are typically 4,000-8,000 bytes (future optimizations will reduce this).
- The number of computational (CPU) steps that the script uses: each step represents 1 picosecond of execution time on a benchmark machine. Typical scripts should consume less than 1,000,000,000 CPU units (1 millisecond).
- The number of memory units that the script uses: this represents the number of bytes that the script allocates. Typical scripts should consume less than 1,000,000 memory units (1MB of memory allocation).
Let’s take a look at example Plutus scripts to understand their execution costs (Figure 1):
Figure 1. Estimated fees for script processing on Cardano
The estimator shows that sending a simple transaction would be as cheap as 0.17 ada, whereas the maximum possible cost for a single script would be 2.17 ada.
The calculation can be extended to DApp execution (see Figure 2). For example, a DApp using three transactions (one simple and two script transactions) might cost ~ 1.50 ada.
Figure 2. Estimated fees for DApp execution on Cardano
The final word
The Alonzo HFC event enabled Plutus script execution on the Cardano mainnet. This was really just the beginning of the journey for Cardano smart contracts. Now, with the launch of major smart contracts projects, we can begin the process of optimization and scaling. This includes the ongoing assessment of actual, real-world smart contract usage.
We need to balance the needs of the user and what is good for the network, speed versus correctness, and – as ever – striking that balance between security, scalability, and decentralization.
Future code/script optimizations and system performance improvements will help to refine the Cardano fees model over time. Together with our developer and stake pool operator communities, we will monitor the growth of smart contracts, optimize the Cardano node and the Plutus interpreter implementations, and make other adjustments to best support our user base in terms of fair and predictable transaction fees.
Check out the Plutus fee estimator and be sure – you can easily estimate the processing fee without losing your funds in case of transaction failure.
Recent posts
Hydra Doom Tournament by Fernando Sanchez
22 November 2024
Quality Engineering at IO: bridging research and reality in software development by Ivan Irakoze
20 November 2024
Black Hawk up: flying with heroes in the wake of Hurricane Helene by Fernando Sanchez
29 October 2024