Navigating Classic Assets and Smart Contract Tokens on Soroban
Fabricius Zatti | Feb 28, 2024
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.
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
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.
The table below shows the average, maximum, and minimum values obtained from each resource.
Results from 220 transactions:
|Minimum Resource Fees
|Ledger Read Bytes
|Ledger Write Bytes
|Ledger Entry Reads
|Ledger Entry Writes
|Events & return value size
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:
|Minimum Resource Fees
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.
Douglas da Silva | Dec 18, 2023