State Channels + Smart Contracts samples


Hi guys,

I was inspecting the Gomuku application sample where channel operations are shown in a web app. From what I saw, seems there is no state channel + Smart contract interaction in this sample; I mean using SC functionality in a state channel message exchange, for example as a transaction verifier ( your move is invalid, your move does not comply with a,b,c, and so on).

The example does effectively open/close channels, trigger updates, and message exchanges - which is undoubtedly useful- , but may be there’s a more complex example including SC for validating state ?

I’m wrong about this use case?

All messages are signed by both parties and both parties can verify that the state is correct by executing the smart contract included in the message.
(Quoted from

Thanks in advance.


Seems to me that internet connectivity loss is an important and big issue in this?


When gomoku game was first written there wasn’t support for contracts in state channels in javascript sdk. That’s why generic messages were used instead. So only the result of the game is secured (after it’s signed by both participants).

Now smart contracts are implemented in state channels in javascript sdk and gomoku contract is being written (should be released soon). I’ll write in this thread when this is done.

You are correct. The benefit of using smart contract instead of generic messages in case of gomoku game is that with smart contract each move is signed by both players and can be executed on chain in case of dispute. So it’s not possible to cheat that you didn’t make a move or you made a different move.


Thanks for your answer, so in the context of two player games I assume that the following “full offchain” model is possible:

  1. players agree to start a new game thru a new channel
  2. they create an instance of a smart contract in the channel. The state of this smart contract is part of the state tree in the channel.
  3. they both play and the Smart contract verifies e.g valid moves, if the game is finished, etc. The smart contract modifies the internal state of the channel , so the players actually exchange Smart Contract state updates.
  4. they finish and the last valid state is enforced in the mainnet.

Now, this is a case where a SmartContract works as bussiness logic for State channel peers, like some kind of "State Channels on steroids "; I mean instead of exchanging simple M messages, we can exchange e.g M' = f(M) messages, transformed through Smart contract logic.

This is correct?

An alternative scenario (this is probably a bad example) could be that a game requires getting global state from the blockchain at start, for example, difficulty handicap to say something, or retrieve player past plays, recorded statistics, and so on.
This should be done from each client -e.g: retrieve state from the blockchain through deployed SC and pass it to the Smart-contract residing in the channel- or it-s possible for a Smart contract in a channel to get data from the blockchain while that channel is open ?

Thanks in advance!