we are clear that in geth console we can add another peer with addpeer command such as


so, my question is how to add another peer in solidity contract or how to call the js command via solidity contract? The solution maybe via modifying the source codes ,but how to modify the codes ? I need a hand to solve the problem.thank you.


Solidity contracts run on the Ethereum Virtual Machine (EVM), you cannot call JavaScript functions from inside the Solidity code.

  • thank you . But if I must achieve the aim, how to do it ? how to modify the source codes? – jiebang Jun 20 '17 at 7:38
  • Maybe there is some other way of what you are trying to achieve. I'm sure you can find better help if you provide more information about your goal. – jeff Jun 20 '17 at 8:15
  • OK, thank you very much. My aim is : I found a private chain, and I want to set a rule , when some new nodes add to my private chain network, one of the main node(I have set already) can call addpeer to add it according to a rule. And the rule may vary aperiodically . so I want to create the rule and add peer in solidity contract. – jiebang Jun 20 '17 at 8:51
  • Assuming you know how the peer discovery protocol works, you can implement this with JavaScript (+Web3), without Solidity. Also see this. – jeff Jun 20 '17 at 9:17
  • Thank you , so you mean I can write a JavaScript source to implement the peer discovery protocol? And run the JS in the geth console? thank you . – jiebang Jun 20 '17 at 9:32

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.