12

If possible, I would like to use parity with my private ethereum network.

This answer (https://ethereum.stackexchange.com/a/9148/4575) provides us a solution that geth will run on the background and parity will pull information from geth.

[Q] Is it possible to run only parity (geth won't run on the background) that is connect to the private etheum network and do mining, deploy contract, send transactions etc.?

If yes is there any well explained tutorial related to adding private network peers to Parity and make Parity to connect into the private network's chain instead of the public ethereum's chain.

Is this link might help me?https://github.com/ethcore/parity/wiki/Configuring-Parity. If yes which parameters should I focus on to change? Also how could I add admin.addPeer("enode://<id>@<ip>:<port>?discport=0"); and provide the --networkid to Parity to allow it to connect into the private network like we could do in geth?

Example by using geth as follows I can connect into my private network:

id="<enodeId>";
datapath="/MyEthereumEbloc"
geth --networkid 23422 --datadir="$datapath" --rpccorsdomain '*' --rpc --rpcaddr "localhost" --rpccorsdomain="*" --rpcport="8545"--bootnodes enode://$id@<ip>:<port>

Please note that I was not able to find any tutorial related make parity connect into private ethereum network, which might be very helpful.

Thank you for your valuable time and help.

alper
  • 8,395
  • 11
  • 63
  • 152

2 Answers2

7

Not sure if I get your question correctly. Assuming you have a private network running with 5 clients on network ID 13337 and myGenesis.json chain configuration.

  • enode://0000..0001@192.168.178.101:36541
  • enode://0000..0002@192.168.178.102:36542
  • enode://0000..0003@192.168.178.103:36543
  • enode://0000..0004@192.168.178.104:36544
  • enode://0000..0005@192.168.178.105:36545

Add these nodes to a file, let's say myPrivateNetwork.txt, one entry per line:

enode://0000..0001@192.168.178.101:36541
enode://0000..0002@192.168.178.102:36542
enode://0000..0003@192.168.178.103:36543
enode://0000..0004@192.168.178.104:36544
enode://0000..0005@192.168.178.105:36545

And subsequently, run Parity with --chain myGenesis.json --network-id 13337 --reserved-peers myPrivateNetwork.txt --reserved-only. Or add it to the config file:

[parity]
chain = "myGenesis.json"

[network]
id = 13337
reserved_only = true
reserved_peers = "./myPrivateNetwork.txt"

This will establish a private network containing only your nodes:

--reserved-peers FILE        Provide a file containing enodes, one per line.
                             These nodes will always have a reserved slot on top
                             of the normal maximum peers. (default: None)
--reserved-only              Connect only to reserved nodes. (default: false)

Adding reserved peers also works from the Web3 console by issuing:

api.parity.addReservedPeer('enode://0000..0007@192.168.178.107:36547')

Note, that you have to enable the parity json rpc api.

You can also run a private development chain with parity --chain dev.

q9f
  • 32,913
  • 47
  • 156
  • 395
  • Thank you @5chdn I am sorry if my question is not clear. enodes does not have to be reserved, any peer can connect to the private network. I was trying to explain that: I know the --network-id and enode://<id>@<ip>:<port>?discport=0 of the node that will allow me to connect into the private network. By using geth I am able to connect into it. So I was wondering by using same information and chain-data created by geth, could parity connect into the private network? – alper Mar 13 '17 at 15:56
  • 1
    Sure, just see my answer and set reserved_only to false. – q9f Mar 13 '17 at 19:04
  • Is myGenesis.json file same as CustomGenesis.json that used under geth init CustomGenesis.json? for example: https://gist.github.com/avatar-lavventura/378fb95285c91d40bf6f1b9f4bf2acd2@5chdn – alper Mar 14 '17 at 01:14
  • 1
    No, Parity uses a slightly different format, but there is a tool to convert geth genesis to parity genesis. Somewhere. – q9f Mar 14 '17 at 08:20
  • 2
    ^ https://github.com/keorn/parity-spec – Joël Mar 15 '17 at 00:50
  • @5chdn How could I open Web3 console to add my peer?, geth console was working but in parity, parity console does not exist – alper Mar 17 '17 at 12:32
  • @5chdn, I did all your guidance but I was not able to connect to my private chain :(. The way I run parity: parity --chain parity.json --network-id 23422 --bootnodes enode://<enode-id>@<IP>:<port#> It gives following output 2017-03-17 15:56:19 0/ 0/25 peers 5 KiB db 7 KiB chain 2 KiB queue 4 KiB sync but nothing happens. – alper Mar 17 '17 at 12:58
  • 1
    Parity Console: https://ethereum.stackexchange.com/questions/13196 / It's better to use reserved peers rather than bootnodes. – q9f Mar 17 '17 at 13:12
  • @5chdn sorry to keep bothering you. parity --chain parity.json --network-id 23422 --reserved-peers myPrivateNetwork.txt seems didn't work as well on my case :( When I use geth I can add the peer as admin.addPeer("enode://enode@IP:port?discport=0");, but parity also does not accept ?discport=0 inside myPricateNetwork.txt. – alper Mar 18 '17 at 05:08
  • 1
    You maybe should get on Gitter and we can sort this out :) – q9f Mar 18 '17 at 08:36
4

To add a reserved peer via JSONRPC API, you can do this with:

curl --data '{"method":"parity_addReservedPeer","params":["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

Make sure you have parity_set JSONRPC API enabled.

You can also call it directly from the Parity console with:

api.parity.addReservedPeer("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770")

For this, ensure you have parity_set DApps API enabled.

q9f
  • 32,913
  • 47
  • 156
  • 395