LogoLogo
English
English
  • Introduction
  • API
  • Methodology
    • Blockspace
    • Fundamentals
      • ๐Ÿ•“Activity
      • โญValue Locked
      • ๐Ÿ’ณEconomics
      • ๐Ÿ”€Convenience
  • General Layer 2 Knowledge
    • ๐Ÿ“œData Availability
      • โšชLight/client and full nodes
      • โŒFault Proofs
      • ๐Ÿ„โ€โ™‚๏ธOnchain Data Availablity
        • ๐Ÿ“„EIP-4844
        • ๐ŸงซData Availability Sampling
      • ๐Ÿ•Š๏ธOffchain Data Availability
        • โš™๏ธGeneral Purpose DACs Mechanism
        • ๐Ÿ“šSources and Extra Material
  • Developer Content
    • โš–๏ธWhich Layer 2 approach is for you?
      • โ†”๏ธState Channels
      • โšกPlasma
      • ๐ŸŒ€Rollups
      • ๐Ÿ”Validiums
    • โ›ฝTransaction Costs
      • โš”๏ธOptimistic vs. Zero Knowledge Rollups
      • ๐ŸคValidium Hybrids
      • ๐Ÿ–ผ๏ธWhat EIP 4844 means for Layer 2s
    • โญRollup Performance
      • โŒ›General Stats
      • ๐Ÿ“จMessaging Latency and Cost
  • OP Chains
    • ๐ŸงฐOP Stack
    • ๐ŸŒŸSuperchain
    • ๐Ÿ›ฃ๏ธRoad to Superchain
      • โœ…Chain Factories
      • โœ…Permissionless Proof System
      • โ˜‘๏ธConfigurable Sequencer per OP Chain.
    • โ›“๏ธChain Knowledge
      • ๐Ÿ”ตBase
      • โšชZora
      • ๐ŸŸขPublic Goods Network
Powered by GitBook
On this page
  • Scenario ๐ŸŒŸ
  • Ups and Downs
  • Optimal for ๐ŸŽฏ
  • Examples and resources ๐Ÿ“š
  1. Developer Content
  2. Which Layer 2 approach is for you?

State Channels

PreviousWhich Layer 2 approach is for you?NextPlasma

Last updated 1 year ago

"State channels are a very broad and simple way to think about blockchain interactions that could occur on the blockchain, but instead get conducted off of the blockchain, without significantly increasing the risk of any participant."

Scenario ๐ŸŒŸ

Imagine a scenario where Emily owns a cozy coffee shop โ˜•, and Jack is a frequent customer. Jack prefers to pay for his coffee in small increments, at a rate of $2 per cup. To streamline this process and avoid numerous small transactions, they decided to use a Layer 2 solution: a state channel.

Here's the process:

  1. Initial Setup: Jack deposits $20 (or its equivalent in ETH or a stablecoin) into a smart contract. This deposit is like a prepaid coffee card โ˜•๐Ÿ’ณ, intended for his future purchases.

  2. Purchasing Coffee: Each time Jack buys a cup of coffee, he sends an off-chain digital "ticket" ๐ŸŽซ to Emily. The first ticket is marked "$2", representing his payment for the first cup. For his second cup, he sends a ticket marked "$4", and this pattern continues with each purchase.

  3. Closing the Tab: When Jack decides to settle his bill, Emily presents the last ticket he sent โ€“ say it's "$16" after 8 cups of coffee โ€“ to the blockchain. The smart contract verifies the signatures of both parties, transfers $16 to Emily, and refunds the remaining $4 to Jack ๐Ÿ’ฐ.

  4. Security Measures: If Emily, for any reason, doesn't close the channel, Jack can initiate a withdrawal period, like 7 days ๐Ÿ—“๏ธ. If Emily fails to submit the highest-value ticket within this period, the smart contract automatically refunds Jack's full deposit. ๐Ÿ›ก๏ธ๐Ÿ”’

Ups and Downs

Upsides:

  1. Efficient Microtransactions ๐Ÿ’ฐ: In scenarios like Emily's coffee shop, state channels enable small, frequent transactions (like buying coffee) without congesting the blockchain. This is similar to Jack buying his $2 coffee without needing a blockchain transaction for each cup.

  2. Flexible and Versatile ๐Ÿคน: These channels can handle various types of transactions, from simple payments to complex contracts. For instance, if Emily decides to offer a loyalty program or special discounts within the same channel, it can be easily integrated.

  3. Interconnected Networks ๐Ÿ”—: If Emily has a channel with Jack, and Jack has another with another vendor, transactions can be indirectly facilitated, creating a network of interconnected channels.

  4. Strong Privacy Properties ๐Ÿ•ต๏ธโ€โ™‚๏ธ: Transactions within a state channel are private, and shared only between participants.

  5. Instant Finality โšก: State updates are considered final as soon as both parties sign, offering a high guarantee of enforceability on-chain.

Downsides:

  1. Limited to Chain Participants ๐Ÿ”’: Channels cannot be used to send funds off-chain to people who are not yet participants.

  2. Capital Lockup ๐Ÿ’ธ: Jack's initial deposit is locked in the channel until transactions are settled. This can be a downside for users who don't want their funds tied up, similar to how larger, more complex channels require significant locked capital.

  3. Operational Complexity ๐Ÿ› ๏ธ: Managing a state channel, especially for more complex arrangements, can be technically challenging. In the coffee shop scenario, if Emily wants to integrate more sophisticated services into the channel, it would require a deeper understanding and management of blockchain technology.

  4. 100% Availability Requirement ๐Ÿšจ: All participants must be constantly available, as unavailability could be costly. While representatives can be used, they pose risks of attack or bribery.

Optimal for ๐ŸŽฏ

Defined Participant Sets

State channels require known participant addresses, and changing participants necessitates contract modifications, unlike sidechains.

Long-Term, Frequent Exchanges

Due to the initial cost of setting up a channel, they are most efficient for long-term use with many state updates.

Examples and resources ๐Ÿ“š

: This article can provide insights into, why it is difficult to design state channels on Ethereum now, how state channels could be applied in various business models and a technical overview of the needed layers in a state channel

: Tom Close's talk from Magmo, where he talks about the hardships of building state channels and state management in the context of a rock paper scissors game they built with state channels.

: Useful for understanding the technical aspects of state channels, which could be beneficial for complex implementations in a business setting.

: This resource explores advanced applications of state channels, which could inspire innovative uses in various business models, including retail or service industries like a coffee shop.

: Vitalik Buterin's 2021 Jan 05 article to Rollups

: Jeff Coleman's article provides a comprehensive explanation of state channels and their components

โš–๏ธ
โ†”๏ธ
โฌ†๏ธ
โฌ‡๏ธ
Jeff Coleman
State Channel Applications by Liam Horne - Medium
Building a State Channel Application - Devcon Archive
Difference Between SideChains and State Channels - Thomas J. Ackermann
State Channel as a Service Based on a Distributed and Decentralized Web - IEEE Xplore
An Incomplete Guide to Rollups
State Channels