How Much Do Soroban Fees Cost? Running Smart Contracts in Stellar

how much do stellar soroban fees cost

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

How Soroban fees are calculated

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 resources

Soroban’s transaction resource fees are determined by six key factors:

  1. CPU Instructions: The number of CPU instructions executed by the transaction.
  2. Ledger Entry Accesses: Reading or writing any single ledger entry.
  3. Ledger I/O: The amount of bytes read from or written to the ledger during the transaction.
  4. Transaction Size: The size of the transaction submitted to the network.
  5. Events & Return Value Size: The size of both the events produced by the contract and the return value of the top-level contract function.
  6. Ledger Space Rent: Payment associated with the ledger entry Time-to-Live (TTL) extensions and rent payments for increasing ledger entry size.

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.

Average transaction costs

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:

ResourcesAverageMaximumMinimum
Minimum Resource Fees215,142823,35045,272
CPU Instructions16,672,41966,832,1053,797,619
Ledger Read Bytes30,55075,312696
Ledger Write Bytes4143,1160
Ledger Entry Reads3101
Ledger Entry Writes2110
Events & return value size1511,3604
Transaction size3321,732116

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:

ResourcesAverageMaximumMinimum
Minimum Resource Fees261,052823,35048,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

Conclusion

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!

About the author.

Alessandra Carneiro
Alessandra Carneiro

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.