Supercharge Your Flutter Apps With Apple Watch Integration
Leandro Pontes Berleze | Sep 25, 2024
Soroban, Stellar‘s smart contract platform launched on Mainnet, brings increased flexibility to the network.
One of the great advantages of the Stellar blockchain network is that classic transactions are the price of their fees compared to other networks.
Now, the question is, will Soroban transactions follow suit?
Today we’re going to explore this question analyzing different contracts and understand what to look out for when calculating the costs of contract call transactions.
Read more: A Guide to Soroban in Defining DeFi on the Stellar Network
Understanding Soroban fees involves breaking them down into two essential components: the inclusion fee and the resource fee.
The inclusion fee represents the maximum bid a submitter is willing to pay for their transaction to be prioritized in the ledger. When the ledger has space, only the base fee of 100 stroops is charged.
This price depends a lot on network congestion and the user’s willingness to wait for ledger inclusion.
The resource fee, on the other hand, hinges on the network resources consumed by the invoked transaction. Simply put, the more complex the transaction, the higher the fee to get it included in the ledger.
Let’s take a closer look at which resources impact the price in this part of the fee calculation.
Soroban’s transaction resource fees are determined by six key factors:
While some resources, like RAM, don’t incur a cost fee, it’s important to note that all resources must be within the network’s maximum limit to be included.
You can find more details on these limits in the official documentation.
To successfully execute a transaction, a fee proportional to the estimated cost of resources must be included in the envelope. If the resource usage exceeds the fee sent, the transaction will fail.
To help with the resource usage estimation, it’s possible to use the soroban-rpc simulateTransaction
method.
This method simulates the execution of the transaction in the ledger, providing information on the expected resource usage. Some values, like CPU instructions, come with a margin of error, with a 20% increase, and a minimum value of 3 million.
If the resource fee sent exceeds the actual resource usage, refunds are only applicable for Events & Return Value Size and Ledger Space Rent resources. Other resources will be allocated and charged as per the user’s request, even if they remain unused in the transaction.
To gain a better understanding of the day-to-day costs associated with these fees, we conducted a profiling analysis on various protocols developed by the community.
While many of these contracts are still in the development phase and require refinement, they offer valuable insights into average costs.
The tested transactions include token transfers, swaps, deposits, withdrawals into liquidity pools, oracle operations, and more.
To gather these metrics, we utilized the profiling functionality within the stellar-plus library. You can find part of the source code here.
The table below shows the average, maximum, and minimum values obtained from each resource.
Results from 220 transactions:
Resources | Average | Maximum | Minimum |
Minimum Resource Fees | 215,142 | 823,350 | 45,272 |
CPU Instructions | 16,672,419 | 66,832,105 | 3,797,619 |
Ledger Read Bytes | 30,550 | 75,312 | 696 |
Ledger Write Bytes | 414 | 3,116 | 0 |
Ledger Entry Reads | 3 | 10 | 1 |
Ledger Entry Writes | 2 | 11 | 0 |
Events & return value size | 151 | 1,360 | 4 |
Transaction size | 332 | 1,732 | 116 |
Looking at the results, the average minimum resource fee comes in at around 215,000 stroops, which equals 0.0215 XLM.
It’s worth mentioning that this figure might be slightly influenced by including read transactions, which do not write to or modify the ledger.
While these read transactions can be executed in the ledger, it’s also possible to use simulations for reads without incurring a fee. Consequently, read transactions are less likely to be encountered frequently.
For a more precise evaluation, let’s narrow down our examination to the 119 transactions that involve ledger modifications. For this case, we’ll focus on visualizing the fees.
Results from 119 transactions with ledger modifications:
Resources | Average | Maximum | Minimum |
Minimum Resource Fees | 261,052 | 823,350 | 48,670 |
Focusing on transactions involving ledger modifications provides a dataset that aligns more closely with real-world scenarios.
The changes aren’t drastic, with the average minimum resource fee at 261,052 stroops, equivalent to 0.0261 XLM.
In the context of the current exchange rate, where XLM is valued at 0.11 USD, this fee translates to only 0.0029 USD. Moreover, the highest fee recorded from these transactions is just 0.0092 USD.
You can check all the results obtained per transaction in this spreadsheet.
You may also like: How To Use Stellar’s Soroban To Write a Bond Smart Contract
In real-world scenarios, it’s natural to have more complex transactions that use more resources, as there will be more data and more security measures. It’s also important to note that this resource fee will be added to the inclusion fee, which may significantly increase based on network congestion.
Overall, Soroban fees are quite reasonable, usually just a few cents. This makes Soroban a cost-effective choice compared to other networks. As Mainnet is about to launch and Soroban usage is expected to grow, we look forward to gaining an even more accurate perspective.
We hope this article has given you a practical understanding of Soroban fees. If you have questions or seek assistance in developing your project with Soroban, please feel free to reach out to us!
Someone who has many hobbies and does them all in an average way. Loves drinking tea and dreams about petting all dogs around the world.