I'm setting a private blockchain using parity rust client.
In geth
I can use admin.nodeInfo
and get enode from there. But how can I get enode in parity client?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityparity
'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.
parity
source code with a new JSON RPC method to get nodeid?
Aug 25, 2016 at 15:43
admin
API - see github.com/ethcore/parity/blob/master/parity/… . So your logs may be the only way.
Aug 25, 2016 at 15:55
parity_enode
to get enode info. See my answer dated Feb 10, 2017 below.
Feb 22, 2017 at 19:51
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
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
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