How can I know / query / call a contract before channel close

Hello!

I’d like to know if it is possible to call a contract static function of a contract that was deployed in a State Channel while it is about to/or closing.

To do that I tried a few alternatives and failed (in my case, initiator issues a channel shutdown):

  1. after the shutdown received by responder and it is signed, if I try to make an static call it fails with: “cannot call send() while not connected”.

  2. in the same scenario, if responder tries to make the static call before signing the shutdown received, it stalls (which I would understand, in some way, if the call weren’t an static one).

  3. is there a “simple” way to query contract-state from state-channel-state after it is closed?

And also I’d like to know if there is a way that, in my case the responder, could cancel a shutdown issued by initiator? (how?)

Thanks,
david

1 Like

Its forwarded. @pegah will get an answer for you.

2 Likes

I don’t think it’s possible currently. Seems to be a limitation of state channels fsm rather than JavaScript SDK. When mutual close is initiated it enters closing state and then it doesn’t recognise static call request.

  1. That makes sense because static call requires active websocket connection.
  2. Due to limitation mentioned previously static call promise will never be resolved in such case. So JavaScript SDK should reject static call if channel is in closing state as long as this limitation exists.
  3. Offchain state is persisted by node and there doesn’t seem to be any way to access it other than connecting to the websocket endpoint. You can however persist it locally if you want (by tracking state changes).

You can try to return null when mutual close transaction is received. But I’m not sure if it works as with offchain updates.

Maybe @Dimitar.Ivanov can say more from the protocol level perspective.

1 Like

Michał thanks for your answer! I understand now why it is not possible.

I’ve read in some document, that, maybe in some future, “sdk” or some client-side component would be able to persist state-channel state, without relying in the node… do you know when that is expected to be implemented?

Also, when a transaction closes the channel and some of its state is persisted to the blockchain, what information is persisted? what should be the way to interpret that?

Any pointer to read about what is implemented and what to expect, would be really welcome!

thanks!
david

Probably it will be first implemented in base aepp but I don’t know when.

It depends on how you close the channel. If both parties agree on mutual close transaction only final amounts are saved on blockchain. Otherwise one party needs to post solo close transaction which has to include proof of inclusion. Here is an excerpt from the documentation about POI:

Proof of inclusion represents the channel’s internal state. At the bare minimum it has to include all accounts and their balances. It must provide enough information to close the channel. Miners are to check balances in it and use this data to update the channel’s on-chain representation. This is how the poster initiates the solo closing sequence. If there are any contracts in the channel and those have balances of their own, they are not provided in the proof of inclusion but they are rather to be force- pushed in subsequent transactions. It is up to participants to decide if they want to post them at all. Thus the accumulative balances of the accounts in the solo-close transaction can be lower than the channel balance persisted on-chain.

1 Like