State Channels And Their Growing Role In Cross-Chain Trading

State channels have emerged as one of the most important blockchain scaling technologies. They make it possible to reduce the data that’s processed by the blockchain mainnet and can therefore facilitate much faster transaction speeds with instant finality.

One of the major advantages of state channels is that they do not require any changes to be made to the underlying blockchain protocol. Rather, they simply move excessive loads away from the blockchain to make them infinitely more scalable.

Understanding State Channels

A state channel is opened when two or more parties create a smart contract on the underlying blockchain that serves as the final settlement layer. The smart contract contains the initial state of the channel as well as the rules that dictate how the channel will function.

As soon as the smart contract has been created, the participants can start transacting with one another off-chain. As they interact with each other, they exchange signed messages that update the channel’s state. These messages are never broadcast to the underlying blockchain and so they don’t need to be validated by the network. Instead, the participants within the state channel validate every transaction themselves.

The state channel will remain open until one of the participants decides to close it. At the moment the channel is closed, the final state will be sent to the blockchain for validation. Once validated, the participants will receive their share of the funds, according to the final state.

Under The Hood

State channels sound like a pretty basic concept, but there are some technical specifics that are necessary to understand.

When the participants in a state channel first open the smart contract, each is required to lock up a portion of the funds within a multi-signature contract to ensure that all of the transactions can be settled in full when the channel is eventually closed. As the participants begin transacting with one another, they will sign messages for each individual transaction and retain a copy for future reference. Within each message is a “nonce”, which can be thought of as a timestamp that allows the smart contract to understand the chronological order of the transactions.

The state channel will be closed when one or more likely, all of the participants submit the final transaction and state to the underlying blockchain. This is where the real beauty of state channels lies. In most instances, the participants will be honest and agree on the closing of the channel and co-sign the final message that’s submitted to the smart contract. Then, once that final state is approved on-chain, the smart contract will execute and enable the participants to receive their final balance of funds.

However, in cases where only one of the parties submits a request to close the channel, without their counterparty’s approval, there will be a delay before the final state is verified on-chain. This delay is necessary to prevent foul play, such as when a user attempts to finalize the channel by submitting an older state that’s weighted in their favor. The other user then has the opportunity to challenge any invalid state update by submitting the latest and most up-to-date version of the channel. Because each message is signed with a nonce, the smart contract will automatically be able to recognize the most recent, agreed upon state of the channel and will therefore overrule any older state.

In other words, no one can game the system. If a dispute is triggered, the other party will have a time limit – known as a challenge window – where they will be able to submit a more recent transaction that alters the final state. The most recent version of the state that’s signed by all parties will always be accepted by the smart contract as the one that’s valid.

State Channels In Action

A number of blockchain scaling solutions have adopted state channels, with one of the most famous being Bitcoin and Litecoin’s Lightning Network. The Lightning Network is one of the most widely used state channels. It’s a decentralized payment channel network that exists as a “Layer-2” so as not to compromise the architecture of Bitcoin or Litecoin.

The Lightning Network employs two different kinds of smart contracts, namely Revocable Sequence Maturity Contracts (RSMCs) to govern the payment channel, and Hashed Time Lock Contracts (HTLCs) which connect the channel to the underlying blockchain. The Lightning Network utilizes its own architecture to process payments made within the state channel, before settling the final outcome on Bitcoin or Litecoin’s blockchain once the channel is closed. In this way, it can dramatically scale transactions on both blockchains, enabling near instantaneous payments.

Besides enabling faster BTC and LTC transactions, the Lightning Network also enables much lower fees. The participants within the channel will only be required to pay miner’s fees for the final transaction, which is made once the state channel is closed. So this fee will be split across all of the previous transactions that occurred within the channel, meaning they are much lower.

Yellow Network is building a more advanced version of state channels that can facilitate cross-chain payments at rapid scale. The network is designed to cater to centralized and decentralized cryptocurrency exchanges and other protocols, and enables them to engage in high-frequency trading across any blockchain, processing thousands of transactions off-chain.

Yellow’s major innovation is the ClearSync protocol, which manages the underlying collateral within each state channel and ensures that every participant agrees on the amount required. It works as a kind of brokerage that’s able to process transactions across multiple blockchain networks with immediate finality.

When two or more parties open a channel, they deposit collateral in the form of YELLOW tokens. This allows each participant to trade in good faith, as they are essentially putting their money where their mouth is. ClearSync provides frequent updates regarding the ratio of the collateral, so each party knows its trades are covered. If one participant wants to engage in a trade that exceeds the available collateral of the other party, they can make a request to them to add more YELLOW as collateral.

The actual trades within the channel are performed by the participants using HTLC smart contracts. ClearSync only manages the collateral that backs each trade. In this way, ClearSync’s state channels do not know the details of each trade, meaning transactions are kept confidential.

State Channels In A Multichain World

As state channel-based networks mature, it’s likely they will play an increasingly important role in facilitating the blockchain and Web3 economy. It has become clear that there will not be one blockchain that rules the world, but rather a whole multitude of blockchains built for specific use cases. This multichain world is inevitably going to result in a dramatic increase in cross-chain activity, and state channels will serve as the foundational technology to enable such transactions to be made safely, with lower fees and instant finality.