Using state channels for scalable smart contracts

I'll guide you through a simple example project so that you can see state channels in action. They use commitment schemes, which are just encrypted transactions that you can't change to commit to your actions before revealing the result when the players decide to show their cards.

The smart contract will be the entry and exit point of the state channel. What happens in-between is outside of the blockchain's control, although we'll define what goes inside each encrypted message so that we can verify it when ending. These are the steps:

  1. Each player that participates in the game must open the state channel by calling a function in the smart contract to define who they are. When they do that, ...

Get Mastering Ethereum now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.