Smart Contract events and/or state inside State Channel

Is there any alternative to contract-events in a State Channel?

We have a contract which provides a “game” over a State Channel.
At some point the game finish and first:
we don’t know if there’s a way to let peers know it did other than polling.

Indeed, we use channel’s events to know when to update things, but we didn’t find something to “close” the contract usage if that’s possible or something which would act like an event we can receive.

Another question we have is:
Is there a way to include a custom “tag” in a contract-transaction which could be used, in the opposite peer to the one who generated the transaction, to detect which kind of transaction was?

From what I see in the update received I get the channel, the static tag “CHANNEL_OFFCHAIN_TX” (can it be changed?), the round number, the contract state (*), and a field called “updates” with something like: [ { tag: 574, version: 1 } ] . Where can I read what is this for?

  • Is there a way “sdk-user” way to “handle” (decode) the contract state included in the transaction?

Thanks,
david

2 Likes

@pegah will get an answer for you!

2 Likes

You can send generic messages with sendMessage() method and listen with on('message') event handler. Transaction tag can’t be changed.

Since aeternity v3.0.0 offchain updates are not part of the transaction anymore. In JavaScript SDK offchain updates can be accessed in following way

channel.on('sign', (tag, tx, { updates }) =>
  console.log(updates)
)
1 Like

Thank you Michał!

I had this question in order to understand if there was a way to understand which kind of update were we signing. That’s right, the other peer can send informational messages to let you know what happen but from security point of view, you can’t rely on that.

Thanks for your answer!