Blog Article
Author
Bri Wylde
Publishing date
Since Soroban’s announcement, it has been touted as a scalable smart contract platform, with its novel fee structure as one of the main supporting points. Scalability means that a network is able to perform under an increased amount of use while still maintaining decentralization and security. Blockchain has the potential to transform cross-border payments, connect the disparate world economy, and open up access to new and existing financial infrastructure. And to do this, it must be able to support a large number of accounts and a high volume of transactions, which means it needs to be designed to scale.
Soroban’s design has taken scalability into consideration from the start. For example, the recent Preview 10 release saw the implementation of the initial phase of a first-of-its-kind state expiration model. This model bounds ledger growth and ensures that the smart contract data on the network is valuable and useful by allowing unused ledger entries to expire while also keeping network participation costs low. There’s a lot more to the state expiration model that you can read about in this recent blog post or in the Soroban docs.
Soroban’s fee model has also been designed with scalability in mind. It differs from other networks in that developers pay a resource fee that is accounted for each resource type, allowing individual resource consumption to be priced independently. Because of this, a block’s budget can also be set per metered resource. This design allows a block’s resources to be used more efficiently, as contracts can be purposefully constructed to consume all available metered resources.
To make this happen, Soroban has a detailed metering system that accurately measures a transaction’s resource consumption. And to make contracts even more efficient, Soroban employs per-transaction resource limitations.
With these systems in place, Soroban smart contracts are certified to be lean, mean fighting machines built to support the scalability, sustainability, and longevity of the Stellar network.
To understand what makes Soroban’s fee structure so unique, let’s go back to the basics — a blockchain can be described as a set of computational resources being sold off to perform work. Each block in a blockchain represents a time period and has a set number of resources available to “sell” before the block is finalized. To have an efficiently running blockchain network, you want all available resources in each block to be used or “sold”.
Most blockchains use an oversimplified resource metering system. The EVM, for example, measures resource consumption in gas. And gas is a single metric that encompasses all the various resources, including compute, memory, and storage. Every block has a total gas budget that is consumed by transactions, and each operation has a gas cost. Since EVM converts multiple different metrics into a single measure, all the underlying resources don’t end up getting used, which assumes wasted resources on every block and makes the system inefficient overall.
Why? Here is a (very) simplified example.
Let’s say we have a new EVM block. This block has an available 100 units of compute, 50 units of memory, and 25 units of storage, all rolled up into an available gas budget. If someone has a storage-intensive transaction that uses all 25 storage units, this will exhaust the entire gas budget for that block. Since the system won’t want to risk another transaction that uses more storage and causes a failure, 100 units of compute and 50 units of memory go unused and wasted in that block.
Alternatively, Soroban exposes each block’s individual resource availability, including ledger entry reads and writes, CPU instructions, and RAM, which allows developers to construct their contracts based on these specific metered resources and helps ensure all resources available in each block are fully utilized. This design enables more transactions to be processed in each block using the same amount of resources.
Soroban’s network efficiency makes it easier for validators to process and validate blocks, ultimately helping to maintain reasonable validator costs so that network participation stays accessible, an important part of decentralization.
Now, of course, developers are encouraged to build their contracts as efficiently as possible to pay a lower transaction fee. And if that isn’t incentive enough, smart contract users also pay a lower fee to invoke less resource-intensive contracts — so developers are further motivated to write efficient contracts to keep user fees low, and people are fairly charged for what they use. It’s also important to remember that Stellar network fees go into a fee pool that is currently locked and not collected by any other individual or organization, so there’s no incentive for validators (or anyone) to increase fee prices. This provides long-term price stability even as adoption and usage grow.
Not only is building efficient contracts encouraged and incentivized on Soroban, but it gives developers the tools to do so.
Since Soroban charges a fee based on resource consumption, it must also have an accurate system to measure these resources. Soroban employs a fine-grained counting and metering system that accounts for the resource costs incurred during a smart contract’s execution and serves as an input for fee computations.
Prior to contract execution, the smart contract developer declares their individual resource limits in the transaction. During the transaction’s lifecycle, the metering model measures the resource consumption and increments the meter accordingly. The meter checks the resource consumption against the resource limits, and if any limit is exceeded, transaction execution is terminated. That way, no one is charged more than they're willing to pay. If execution finishes within the specified limits, the metered totals are recorded and used for fee calculations.
This detailed metering system makes Soroban’s granular resource fee possible and incentivizes resource efficiency.
While the fees and metering structure encourages optimized smart contract design, resource constraints truly enforce it. Soroban has a global network per transaction limit on the number of resources a transaction can consume. These resource limitations are, like other network settings, determined by a validator vote as part of the Stellar Consensus Protocol (SCP), an example of how governance is decentralized on the Stellar network. These limitations are not set in stone, and validators can vote to adjust them in response to network usage and ecosystem needs.
Soroban’s resource limitations force developers to be economical when writing contracts and to think more carefully about how they’re going to use resources more effectively. Although this may be more work upfront, it helps keep validator costs low because there is less waste on the network. The Stellar network’s validators only require 8GB of RAM (unlike, for example, Solana’s recommended 256GB of RAM or more), and resource constraints will help keep it that way.
Resource limitations do more to ensure that what is on the network is efficient and valuable and discourage the creation of unrestricted bad traffic and poor, spammy use cases.
Soroban designers are making deliberate, well-thought-out decisions to support scalability. State expiration, resource fees, a finely-grained metering system, and resource limitations contribute to having valuable and efficient smart contracts and fair and predictable prices, ultimately leading to a sustainable and scalable blockchain network.
If all this talk of scalability and sustainability inspires you, there are many ways to get involved! Soroban is currently live on Futurenet, a shared test network, with Mainnet launch slated for later this year. Check out the docs if you’re interested in tutorials and informative content, head to the Dapps Challenge for a step-by-step course that teaches you about building dapps on Soroban, and if you’re ready to start contributing, Sorobounty Spectacular is now accepting submissions for dapp-focused educational content.
And, as always, the Stellar Developer Discord is a great place to learn and get questions answered during your Soroban journey.