Skip to main content

Generate a Session Key

Generate the key

Make the request from your VM (where your collator node container is running) using the following command:

curl -X 'POST' \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' http://localhost:9944

Copy the key from the response:

{"jsonrpc":"2.0","result":"0xf22d82cfcf4402990a0bef3abefd1e58217ff3a86c548d30f1495fd529460d76","id":1}

In this case, the key is:

"0xf22d82cfcf4402990a0bef3abefd1e58217ff3a86c548d30f1495fd529460d76"

Associate your session key with your collator account

Open the Developer tab, and click Extrinsics, there you'll need to submit the following extrinsic

Developer -> Extrinsics -> session -> setKeys(keys, proof)

NOTE

You can use any krest endpoint to submit setKeys sxtrinsic, including the endpoint from your VM with collator node.

Extrinsics

  1. Paste your session key into the aura: SpConsensusAuraSr25519AppSr25519Public field
  2. Paste 0x00 into the field proof: Bytes
  3. Click Submit Transaction
NOTE

After using setKeys extrinsic, you can connect back to the public endpoint.

Double-check that your session key is associated with your wallet address

Open the Developer tab, and click Chain state. There, you'll need to submit the following state query:

  1. DeveloperChain stateSessionnextKeys

Session Keys

  1. Toggle the switch include option and select your collator address in the AccountId32 field.
  2. Click the + button.
  3. Confirm that your key is displayed.

Remove unsafe rpc methods from your node

Remove --unsafe-rpc-external and --rpc-methods=unsafe methods, which we needed in the beginning, and rerun the container.

sudo docker run -d -v krest-storage:/chain-data -p 9944:9944 -p 9933:9933 peaq/parachain:krest-v0.0.6 \
--collator \
--parachain-id 2241 \
--chain ./node/src/chain-specs/krest-raw.json \
--base-path chain-data \
--port 30333 \
--rpc-port 9944 \
--rpc-cors=all \
--execution=wasm \
--out-peers 50 \
--in-peers 50 \
-- \
--execution wasm \
--chain ./node/src/chain-specs/kusama.json \
--port 30343 \
--sync warp \
--rpc-port 9977