[Solved] Having problem in creating channel

Hi guys,

I am trying to play around with statechannel but got stucked. I am following this tutorial to start with in my private aeternity network.

As you can see, on left hand side, I have initiator and on the right, I have res ponder.

  • At first the responder inittiated the request to open fsm on port 13179.
  • The initiator then open fsm from his side
  • The responder then make channel_open reqst
  • Then initiator accepts it by channel_accept
  • Then initiator calls sign.initiator_sign method but after that nothing happend

I was expecting that the initiator will be asked for privatekey to sign the tx and then send that to responder (responder will get funding_created event). The responder then sign the transaction using his private key. Then channel_create_tx request should be sent to blockhain by initiator and he should receive the channel id and hence the channel will get created.

but none of these happens. Am I missing something?

3 Likes

The channels.sign.initiator.sign message is a signing request from the State Channel FSM to the WebSocket client. The client needs to add its signature to the transaction and send it back using the channels.initiator.sign method.

See the description here, and an example message flow here.

3 Likes

yes I understand that. Read that documentation. but how do I pass the privatekey for channels.sign.initiator.sign message? Please see in the left console, once the initiator gets the channels.sign.initiator.sign message, the terminal is getting disconnected. how do I pass the priavate key?

1 Like

First of all: please don’t send your private key :slight_smile: Like - don’t send it even to a trusted node. Nodes run on servers and those could get compromised. Please keep the private key locally in the wallet where it bellongs.

Do you use a SDK or do you intend implementing it on your own? If you go the latter - you must handle siging in your application. The WebSocket API expects a signed transaction (and not a private key :slight_smile: ).

From the link Ulf posted above:

Initiator is to decode the transaction, inspect its contents, authenticate it, encode it and then post it back via a WebSocket message:

{
  "jsonrpc": "2.0",
  "method": "channels.initiator_sign",
  "params": {
    "signed_tx": "tx_+MsLAfhCu..."
  }
}

You receive the transaction, inspect it, sign it and return it signed. The FSM will never ever sign something for you as this this moves way too much trust in it. It is up to the client/service to authenticate transactions. The FSM will check that they’re correctly authenticated and will dispatch them to other FSM which will do the same. One FSM does not trust the other but yet FSMs keep you from sending wrongly signed transactions.

1 Like

oh so I was doing wrong then. My final intention was to implement using the JS SDK but I was trying out the WebSocket API in wscat to see what happens. Could you please point out the doc for JS sdk ?

2 Likes

You certainly can play with it but you will have to sign the transactions yourself.

You can find the JS SDK here. Since I am overloaded with FSM work, I am not following their progress and I am not sure which JS SDK APIs are documented. I will leave that to @nduchak.chain to elaborate.

1 Like

Hello @vishwas_hypermine, here you can find an API docs for State Channel and also some examples:

2 Likes

@nduchak.chain can you please confirm examples are up to date with latest SDK? I see they haven’t been updated since mid December (tests) and late November (demo).

Even if not up to date, they could be used as an inspiration :slight_smile: Still it is worth knowing if they are up to date, though.

2 Likes

All tests are passing and no new feature was added there, so i guess that is the latest examples

2 Likes

@vishwas_hypermine I think you would find it useful if you had a look here: GitHub - aeternity/ae-channel-service it showcases usage a channels. It can automatically start the responder for you, and you can try interactive interface for the initiator and also tinker with your own (JS based or how ever you prefer).

4 Likes

@aleksandar.chain @nduchak.chain @dimitar.chain Guys honestly, I was not expecting this much of help. I am really overwhelmed. Thank you all. I am sure these documentation will help me a lot. so Thank you :slight_smile:

You guys rocks! Let’s build the AE community more stronger.

10 Likes