How to get node ID?

kostaskostas Member Posts: 16
Is there a function in web3 that allows me to get the node's hexadecimal ID?

(The first part of this node's enode URL basically.)

Thank you.


  • jesus666jesus666 Member Posts: 62 ✭✭
    Can you explain what you mean by node ID? And enode URL?
  • kostaskostas Member Posts: 16
    If you run admin.nodeInfo() on the console you will get back an object with the properties I'm looking for.

    "Node ID" is labeled as "NodeID", and "enode" as "NodeUrl".
  • jesus666jesus666 Member Posts: 62 ✭✭
    At the moment, I don't think there is a way to do this with web3. What do you need this for?
  • alexykotalexykot Member Posts: 2
    Same question here.

    Here's the situation:
    I have a random remote machine's IP address that responds on port 30303. I want to force my geth to connect to that machine, but I cannot do that, since the admin.addPeer() method requires enode URL, which needs correct NodeID apart from the IP and port. This is why I need to somehow get NodeID before I will connect to that peer.
  • alexykotalexykot Member Posts: 2
    Well, as far as I've figured out by now - to obtain the NodeID I'll need to use RPLx Node Discovery. No idea yet how to do that, but I'll keep on lurking. Any leads on that would be appreciated.
Sign In or Register to comment.