14

I'm setting a private blockchain using parity rust client.

In gethI can use admin.nodeInfo and get enode from there. But how can I get enode in parity client?

4 Answers 4

3

parity's enode info is written to the console when you start the program.

user@Kumquat:~$ parity 
2016-08-26 00:57:35 Starting Parity/v1.2.2-beta/x86_64-linux-gnu/rustc1.10.0
2016-08-26 00:57:35 Using a conversion rate of Ξ1 = US$11.22 (21220608000 wei/gas)
2016-08-26 00:57:35 Configured for Frontier/Homestead using Ethash engine
2016-08-26 00:57:36 Public node URL: enode://031b1e872cea345c5b6b2ff9dfc16213021071bb320987fdf9881f4500880e57a5a8d6b8b57aaf0de263df0a88d757f978039e09fa9758c4d814850c4172ddf7@0.0.0.0:30303
...

Your enode info is enode://031b1e872cea345c5b6b2ff9dfc16213021071bb320987fdf9881f4500880e57a5a8d6b8b57aaf0de263df0a88d757f978039e09fa9758c4d814850c4172ddf7@0.0.0.0:30303.

0.0.0.0 is your localhost. Replace it with your computer's IP address if you want to connect to the parity node from other computers.

5
  • 1
    Thank you, I've found that. I'd like to automate the process for private Blockchain , e.g. to make a query to parity, save enode to index.html, serve it from local web server , and other nodes will curl this URL to construct their bootstrap setting Aug 25, 2016 at 15:03
  • the only way is to parse the log? .. or to modify parity source code with a new JSON RPC method to get nodeid? Aug 25, 2016 at 15:43
  • 1
    I just scanned through the source code and could not find any admin API - see github.com/ethcore/parity/blob/master/parity/… . So your logs may be the only way. Aug 25, 2016 at 15:55
  • 1
    I searched and tested the JSONRPC API documented at github.com/ethcore/parity/wiki/JSONRPC-ethcore-module but no nodeInfo available. Aug 25, 2016 at 16:06
  • @IgorBarinov - there is a JSON RPC method parity_enode to get enode info. See my answer dated Feb 10, 2017 below. Feb 22, 2017 at 19:51
10

Another way to get enode information is to send a POST request with the header Content-Type: application/json to the RPC port of the node with the following body:

{ "method": "parity_enode", "params": [], "id": 1, "jsonrpc": "2.0" }

Official documentation: https://wiki.parity.io/JSONRPC-parity-module.html#parity_enode

1
  • 2
    here is a handy snippet: curl -H "Content-Type: application/json" -k --data '{ "method": "parity_enode", "params": [], "id": 1, "jsonrpc": "2.0" }' -X POST localhost:8545 Jan 12, 2020 at 16:54
4

Parity doesn't include a Javascript interpreter. However, as per the documentation, if you first install node/NPM then you'll be able to install and use the existing Ethereum Web3 API.

$ npm install web3

$ node
> Web3 = require("web3")
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
> web3.eth.blockNumber
743397
1
  • 2
    There is no admin.nodeInfo if not to use --geth compatibility which is like to avoid due to bugs in geth Aug 25, 2016 at 15:10
2

Finally I wrote a workaround with a bash script. I run it on a node using foreman and it writes nodeId to a static web server. Other nodes use curl to get nodeId for bootstrapping.

touch /var/log/parity.log
tail -f /var/log/parity.log | while read LOGLINE
do
   [[ "${LOGLINE}" == *"enode"* ]] && echo $LOGLINE | grep -oEi '(enode.*@)' > /var/www/index.html
done

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.