0

I have a local node with validators Alice and Bob. I've created a node key using this command

subkey generate-node-key --file ./.keys/node-key

Can I use the node key with --validator? Because I saw an example creating a node with only node key and validators connecting that node. What is the correct way of doing this?

2 Answers 2

2

Yes you can use the --validator flag and the --node-key or --node-key-file at the same time. Keep in mind that the --node-key will have precedence over the other one.

Note if you are using the --alice or --bob flags, the --validator flag is not required.

Additionally, you can also use the node itself to generate the same identity instead of using subkey like:

./target/release/node-template key generate-node-key

# Local Identity
12D3KooWJHhnF64TXSmyxNkhPkXAHtYNRy86LuvGQu1LTi5vrJCL
# Node Key
86e77fbcc353717cd95cb8861f6763b250384af1289bd45f24b0a477f620fc5b

or save it to a file:

./target/release/node-template key generate-node-key --file ./.keys/node-key

Then, you can run the node like:

# Using the node key directly (only for dev)
./target/release/node-template --validator --node-key 86e77fbcc353717cd95cb8861f6763b250384af1289bd45f24b0a477f620fc5b

or

# Using the file
./target/release/node-template --validator --node-key-file ./.keys/node-key

And when the node is running, you'll see that the node identity is the same as the one generated by the node or subkey

2022-08-28 17:21:09 🏷  Local node identity is: 12D3KooWJHhnF64TXSmyxNkhPkXAHtYNRy86LuvGQu1LTi5vrJCL    
3

The node key is the identity of your node.

When you boot the node, you will get that too.

It will be stored at <DATA-DIR>/chains/<CHAIN>/network/secret_ed25519.

There are many ways to use it.

  1. put it in that folder
  2. replace the existing file's content
  3. ./node --node-key-file /path-to-the-node-key

Just a note here.

I generally don't generate the node key from the subkey.

You just need to run `./node --node-key-file a'.

If the a does not exist, the node will automatically create an a node key file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.