[Ethereum] Not able to get admin.addPeer() run

go-ethereumprivate-blockchaintestnetswindows

I have installed ethereum(go-eth) in a folder named "blockchain". In that "blockchain" folder, i have 2 more folders, 'node2' and 'node3'.

Step 1:

I have used the following genesis.json file and stored the same json file in both folders:

{
"nonce": "0x0000000000000042",
"timestamp": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x0",
"gasLimit": "0x8000000",
"difficulty": "0x400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"alloc": {

 }
}

saved the file with name "genesis.json"

Step 2:

For initializing the genesis block i executed the following commands from 2 different command prompts:

terminal 1(node2):

geth init "C:\Rahul1306\blockchain\node2\genesis.json" networkid 100

terminal 2(node3):

geth init "C:\Rahul1306\blockchain\node3\genesis.json" networkid 100

Genesis block gets initialized and space is allocated to me, for both nodes.

Step 3

Now i run the following commands to get "chaindata" and other files in respective nodes:

terminal 1(node2)

geth --identity "node2" --ipcdisable --rpc --rpcport "8001" --rpccorsdomain "*" --datadir "C:\Rahul1306\blockchain\node2" --port "30304" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3,personal,admin" --autodag -verbosity 6 --networkid 100 --nat "any" console

terminal 2(node3)

geth --identity "node3" --ipcdisable --rpc --rpcport "8002" --rpccorsdomain "*" --datadir "C:\Rahul1306\blockchain\node3" --port "30305" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3,personal,admin" --autodag -verbosity 6 --networkid 100 --nat "any" console

All the required files are added in both the folders

Step 4

I use the following command in both the terminals to fetch their enode address:

admin.nodeInfo

I receive the following addresses:

node2:

enode://b94f327b518b68f33304078352f7b74cd6290c7601f42ec5cc5f4f50813de2
489171769124f93a4047f1e55a49aee6e5a45869b40bb0b18e395acd0bb40b625e@[::]:30305

node3:

enode://b94f327b518b68f33304078352f7b74cd6290c7601f42ec5cc5f4f50813de2
489171769124f93a4047f1e55a49aee6e5a45869b40bb0b18e395acd0bb40b625e@[::]:30305

Step 5

Now in order to connect these nodes/ attach them to the private network, I use the following command:

Here i am trying to add node3 as a peer of node2. So the following command is executed on terminal 1 ,i.e on node2 terminal.
Notice, i have changed '[::]' with localhost address,i.e '127.0.0.1'

admin.addPeer("enode://b94f327b518b68f33304078352f7b74cd6290c7601f42ec5cc5f4f50813de2
489171769124f93a4047f1e55a49aee6e5a45869b40bb0b18e395acd0bb40b625e@127.0.0.1:30305?di
scport=0")

Now, here is where the problem occurs. I should receive a boolean value, 'true'. Both the geth consoles are working and i execute this command and i receive the following error:

(anonymous): Line 1:15 Unexpected token ILLEGAL (and 2 more errors)

I am not able to understand where i went wrong. So, i need to be able to add the above two nodes as peers in private blockchain network. Please help!

Best Answer

Step 2:

Use --datadir while initializing the genesis file. And the command should be --networkid not networkid

Step 3:

Post your output for the commands so that we can check whether you successfully started the private blockchain with the custom genesis block.

Step 4:

Your enode information is wrong. According to your commands in Step 3, both the nodes should have different enode URIs and node 2 should have port 30304. Either you posted the wrong output or you created only one node.

Step 5:

You don't need the ?discport=0 in the end of enode URI.

Related Topic