Ajuda a traduir aquesta pΓ gina

🌏

Estàs veient aquest pàgina en anglès perquè encara no l'hem traduït. Ajuda'ns a traduir aquest contingut.

Aquesta pΓ gina estΓ  incompleta. Si ets un expert en el tema, si us plau edita aquesta pΓ gina i afegeix-hi la teva saviesa.

State Channels

William Entriken
Darrera ediciΓ³: @fulldecent, August 1, 2021
Edit page

State channels allow participants to transact x number of times off-chain while only submitting two on-chain transactions to the Ethereum network. This allows for extremely high transaction throughput.

Prerequisites

You should have a good understanding of all the foundational topics and a high-level understanding of Ethereum scaling. Implementing scaling solutions such as channels is an advanced topic as the technology is less battle-tested, and continues to be researched and developed.

Channels

Participants must lock a portion of Ethereum's state, like an ETH deposit, into a multisig contract. A multisig contract is a type of contract that requires the signatures (and thus agreement) of multiple private keys to execute.

Locking the state in this way is the first transaction and opens up the channel. The participants can then transact quickly and freely off-chain. When the interaction is finished, a final on-chain transaction is submitted, unlocking the state.

Useful for:

  • lots of state updates
  • when number of participants is known upfront
  • when participants are always available

There are two types of channels right now: state channels and payment channels.

State channels

State channel are perhaps best explained through an example, such as a game of tic tac toe:

  1. Create a multisig smart contract β€œJudge” on the Ethereum main-chain that understands the rules of tic-tac-toe, and can identify Alice and Bob as the two players in our game. This contract holds the 1ETH prize.

  2. Then, Alice and Bob begin playing the game, opening the state channel. Each moves creates an off-chain transaction containing a β€œnonce”, which simply means that we can always tell later in what order the moves happened.

  3. When there's a winner, they close the channel by submitting the final state (e.g. a list of transactions) to the Judge contract, paying only a single transaction fee. The Judge ensures that this β€œfinal state” is signed by both parties, and waits a period of time to ensure that no one can legitimately challenge the result, and then pays out the 1ETH award to Alice.

Payment channels

Simplified state channels that only deal with payments (e.g. ETH transfers). They allow off-chain transfers between two participants, as long as the net sum of their transfers does not exceed the deposited tokens.

Pros and cons

ProsCons
Instant withdrawal/settling on Mainnet (if both parties to a channel cooperate)Time and cost to set up and settle a channel - not so good for occasional one-off transactions between arbitrary users.
Extremely high throughput is possibleNeed to periodically watch the network (liveness requirement) or delegate this responsibility to someone else to ensure the security of your funds.
Lowest cost per transaction - good for streaming micropaymentsHave to lockup funds in open payment channels
Don't support open participation

Use state channels

Multiple projects provide implementations of state channels that you can integrate into your dapps:

Further reading

State channels

Payment channels

Know of a community resource that helped you? Edit this page and add it!

β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–‘β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œβ–’β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–€β–’β–Œβ–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–Œβ–’β–’β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–€β–’β–’β–’β–β–‘β–‘β–‘ ░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░ β–‘β–‘β–‘β–‘β–‘β–„β–„β–€β–’β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–’β–’β–„β–ˆβ–’β–β–‘β–‘β–‘ β–‘β–‘β–‘β–„β–€β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–€β–ˆβ–ˆβ–€β–’β–Œβ–‘β–‘β–‘ β–‘β–‘β–β–’β–’β–’β–„β–„β–’β–’β–’β–’β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–€β–„β–’β–’β–Œβ–‘β–‘ β–‘β–‘β–Œβ–‘β–‘β–Œβ–ˆβ–€β–’β–’β–’β–’β–’β–„β–€β–ˆβ–„β–’β–’β–’β–’β–’β–’β–’β–ˆβ–’β–β–‘β–‘ β–‘β–β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–Œβ–ˆβ–ˆβ–€β–’β–’β–‘β–‘β–‘β–’β–’β–’β–€β–„β–Œβ–‘ β–‘β–Œβ–‘β–’β–„β–ˆβ–ˆβ–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–’β–Œβ–‘ β–€β–’β–€β–β–„β–ˆβ–„β–ˆβ–Œβ–„β–‘β–€β–’β–’β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–β–‘ β–β–’β–’β–β–€β–β–€β–’β–‘β–„β–„β–’β–„β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–’β–’β–’β–Œ ▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░ β–‘β–Œβ–’β–’β–’β–’β–’β–’β–€β–€β–€β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–‘β–’β–’β–’β–Œβ–‘ ░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░ β–‘β–‘β–€β–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–‘β–’β–‘β–’β–‘β–’β–„β–’β–’β–’β–’β–Œβ–‘β–‘ β–‘β–‘β–‘β–‘β–€β–„β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–„β–„β–„β–€β–’β–’β–’β–’β–„β–€β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–€β–„β–„β–„β–„β–„β–„β–€β–€β–€β–’β–’β–’β–’β–’β–„β–„β–€β–‘β–‘β–‘β–‘β–‘ β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–€β–€β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘

Ajuda'ns amb aquesta pΓ gina

Si ets un expert en el tema i vols contribuir, edita aquesta pΓ gina i escriu tot el que saps.

SerΓ s reconegut i estarΓ s ajudant a la comunitat Ethereum!

Utilitza aquesta opciΓ³ flexible plantilla de documentaciΓ³

Dubtes? Pregunta'ns al canal #content al nostre Servidor Discord

Edita la pΓ gina
SegΓΌentSidechains
πŸ‘‰