0

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

admin.addPeer("enode://41bd7d2fe91b344f0ca4ac89c217d688ef90a3616927acec428adddbc69dd2ac5470a489fd2beb67719cbd481436b98284ef9eac50efa49f55fe33e804818520@10.0.50.91:30303")

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.

0

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.