what we’ve discovered

What Is Runes State Machine (RSM)?

November 1, 2024

Samara Asset Group's corporate news image, White logo on black background.Samara Asset Group's corporate news image, White logo on black background.Samara Asset Group's Ad Hoc news image, White logo on black background.Samara Asset Group's Ad Hoc news image, White logo on black background.

New use cases keep coming to the Bitcoin blockchain, while the decentralized finance (DeFi) sector brings new opportunities for this ecosystem to grow. 

This is where the Runes State Machine (RSM) comes in, as it aims to enable the Runes protocol with more complex capabilities, required for decentralized applications (dApps) on Bitcoin. For now, the protocol is mainly used to issue fungible tokens on this blockchain.

In this article, we discuss the idea behind the RSM, how it works, and some potential use cases for it. 

What Is Runes State Machine & Why Was It Created?

The Runes State Machine (RSM) is an important mechanism developed for the Runes framework to enable DeFi on Bitcoin. It serves as the runtime environment for the pre-defined contracts, which can be deployed and run in RSM.

Also, this mechanism introduces decentralized computing capabilities to the Runes protocol. It adds programmability to Runes tokens and enables complex decentralized applications like in the DeFi sector.

Why was it created? 

The RSM was developed to address the limitations of traditional Finite State Machines (FSMs) in the DeFi sector. FSMs struggled with the complex demands of off-chain state channels and smart contracts, leading to the need for a more capable system.

RSM elevates the capabilities of the basic framework of FSMs by adding improved efficiency, flexibility, and security. This is crucial for DeFi applications, where many transactions and contracts are now moved off the main blockchain to reduce costs and increase speed.

Since the Bitcoin network focuses on security and decentralization, building financial applications with complicated state transitions requires a much better system to mitigate risks while scaling smart contract functionality.

Now that we know the origin and functionality of RSMs, let’s take a look at how these work. 

How Does the Runes State Machine Work?

The Runes State Machine updates the internal states of the token based on the pre-defined states and state transition functions in the smart contract. 

RSM is the runtime environment for each Runes token. These tokens don’t need to be transferred to RSM for computing, while the state update rules are pre-defined in the contract. 

Developers of this solution claim that the computing process based on RSM is entirely decentralized and does not require custody of user assets.

The functioning of an RSM can be described as follows. 

State Representation

Each step in a financial process or contract is represented as a state. For example, in a decentralized lending protocol, the states might be "Loan Requested," "Loan Funded," "Repayment Pending," and "Loan Closed."

Transition Rules 

Any transitions between these states are governed by specific rules, such as a trigger condition (e.g., a loan being fully funded) or input events (e.g., a repayment being made). The system transitions from one state to another only when certain conditions are met.

This mechanism helps to ensure that each step in a financial operation is completed successfully before moving to the next stage.

Off-chain Computation 

Many operations in the DeFi ecosystem involve off-chain state transitions to reduce on-chain computational and storage costs. 

For example, in Bitcoin's Layer 2 solutions (like the Lightning Network), state transitions can happen off-chain but still be enforceable on-chain when necessary. These take place using mechanisms like cryptographic proofs or hash-time lock contracts (HTLCs).

Security and Scalability

RSM also focuses on security and scalability, particularly in handling off-chain transactions and smart contracts. All this is done while ensuring that these contracts are always auditable and enforceable on-chain when needed. 

By using RSM, developers can potentially create more sophisticated DeFi systems that are faster and cheaper but retain the security guarantees of the Bitcoin blockchain.

Possible Use Cases & Applications of RSM in Bitcoin DeFi

The Runes State Machine has a wide array of applications within the Bitcoin DeFi ecosystem. Below are some potential, though currently theoretical, use cases.

Lending and Borrowing Platforms

RSM can model the lifecycle of a loan, from its creation to repayment. It can track the loan’s state at each stage. The model can help carry out smooth transitions between these states, preventing fraud, administrating terms, and carrying out the loan contract predictably.

Decentralized Exchanges (DEXs)

RSM can be used to manage trading transactions, including order placements, matches, executions, and settlements. It ensures that all trades follow a defined sequence, reducing the risk of errors or manipulation.

Token Swaps and Automated Market Makers (AMMs)

In AMMs, where users trade tokens without an order book, RSM can track the liquidity of pool states, token supply, and demand changes to ensure the system remains balanced. This can help manage token pools efficiently while providing greater transparency and trust in decentralized exchanges.

Escrow Services

An RSM can also process the states involved in escrow services, keeping the funds locked, to be released only when all conditions are satisfied. It can prevent disputes and ensure that transactions are completed fairly without the need for intermediaries.

Insurance Protocols

In DeFi insurance protocols, RSM can handle the state transitions from policy issuance to claim processing. The smart contract can impose that policy conditions must be met before any claim is paid, helping to mitigate fraud.

Payment Channels (Layer 2 Networks)

In payment channels, RSMs manage the off-chain state transitions while keeping the on-chain security intact during the periodic settlement on-chain. These state machines allow for efficient, low-cost payments between users by managing state transitions for each payment.

NFT Marketplaces

Managing non-fungible tokens (NFTs) involves complex state transitions, especially while hosting auctions or conducting sales. RSM can help manage the lifecycle of an NFT sale. For example, ensuring that the ownership transfers occur seamlessly once payment is made.

Potential Drawbacks of RSM

Despite its benefits, RSM does come with potential drawbacks:

Complexity

While RSM focuses on increasing the level of security and efficiency, it also adds complexity to the system. Developers need to be very careful in designing and implementing state transitions. Any mistakes can introduce bugs or unintended behaviors if not done correctly.

Additionally, it can be complex to maintain a sync in both on-chain and off-chain state transitions.

Off-chain Risks

In Layer 2 networks, transactions are often bundled and updated off-chain. Now that the state transitions are occurring off-chain, there may be risks associated with making them secure.

On top of that, issues like network delays or loss of connectivity can also delay state updates and lead to confusion.

Resource Intensity

Managing states in a decentralized system is a resource-intensive activity, especially in environments where smart contracts are executed frequently.

The computational and storage requirements, even if optimized through off-chain processes, can still be significant for large-scale applications.

Adoption and Integration

Since RSM is tailored specifically for Bitcoin DeFi and isn’t yet widely adopted across different platforms, there may be integration challenges.

The ecosystem is still in development, meaning tools and frameworks around RSM might still need improvement in user-friendliness.

Wrapping Up

The Runes State Machine is a new innovation that has the potential to bring more DeFi activity to the Bitcoin ecosystem. 

Still under development, it will be an exciting project to follow to see how it could impact Bitcoin in the future. 

Sign up for Samara’s Monthly Market Commentary to stay updated on the latest trends and developments in Bitcoin and tech-driven alternative assets.