Operation instruction problem
In the chapter How to code the model we've warned against the usage of blockchain operations instructions inside your lambda.
The complete list of instructions is available in the Michelson Reference. It includes:
Understanding why these instructions shall not appear in your
apply_ lambda will help you understand how state channels work.
Why can these instructions not appear in your model?
We can split these instructions into two parts. The first part contains those which create operations:
apply_ lambda doesn't return operations, they would necessarily be destroyed further in the code without being used. We cannot let the
apply_ lambda return operations because it would let users create operations in the name of the platform contract. Furthermore, the
apply_ lambda is intended to be executed onchain only for conflict resolution so spawning operation only when the lambda is executed doesn't make sense.
The second part contains the instructions that gather information about the context. The problem is that the context may differ between the move signature and when it is pushed on-chain. It would be against the idea that the game platform can arbitrate in the same context as it were off-chain.
What are the workarounds?
TRANSFER_TOKENS can be replaced by the settlement mechanism.
All the context instructions can be replaced by signed data either by both players or by a trusted source like an Oracle.
For example, instead of
NOW you can make both players sign the date timestamp and the
move_nb. In the game state you'd have the two public keys and have the
apply_ lambda verifying the signatures and the
move_nb. In this particular case, the logic of your contract must take into account that the
move_data can be pushed at anytime.
We don't have solution for the other instructions. If you want to use them in your lambda you should consider that state channels are probably not the right way to handle your problem.