I need to get the enode of my geth nodes before I start them up.. is there any way to do this via a command other than actually starting up the node ?


Using node hex in nodekey file under .ethereum/geth/nodekey and bootnode utility.

Assuming you are using Linux.

Check your nodekey hex :

$ cat ~/.ethereum/geth/nodekey

Then with bootnode utility :

$ bootnode -nodekeyhex 2ad3a9ccd99926514e77501c33c5fdbae6ecfdc6fc82853bc8f28772b13cd2df -writeaddress

One of the binaries that can be generated by the go ethereum implementation is bootnode that can be used (as the name suggests) to create a bootnode, i.e. a node that is involved only in the p2p management. You can exploit this tool to generate a new id for the node:

bootnode -genkey <your-node-key-file>

Afterward you can use this file with geth:

geth --nodekey <your-node-key-file> -port $PORT

Obviously, to store the complete enode in a variable you need to have access to the IP and the port in bash:

 NODEKEY=$(bootnode -nodekey <your-node-key-file> -writeaddress)

bootnode -nodekey ~/.ethereum/geth/nodekey -writeaddress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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