3

I'm trying to setup 2 node ethereum network in my local desktop one on port 30305 and another on 30305.

set up Node 1 -

$ ./build/bin/geth --datadir data/node1  --port 30304  --networkid 1234 init genesis/genesis.json
WARN [11-05|01:07:35] No etherbase set and no accounts found as default 
INFO [11-05|01:07:35] Allocated cache and file handles         database=/home/rajkumar/Coding/ethereum/go-ethereum/data/node1/geth/chaindata cache=16 handles=16
INFO [11-05|01:07:35] Successfully wrote genesis state         database=chaindata                                                            hash=a3c5c1…d6926b
INFO [11-05|01:07:35] Allocated cache and file handles         database=/home/rajkumar/Coding/ethereum/go-ethereum/data/node1/geth/lightchaindata cache=16 handles=16
INFO [11-05|01:07:35] Successfully wrote genesis state         database=lightchaindata                                                            hash=a3c5c1…d6926b
[rajkumar@localhost go-ethereum]$ ./build/bin/geth --datadir data/node1  --port 30304  --networkid 1234 console 2>console-node1.log
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.1-unstable-0956967e/linux-amd64/go1.9
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> admin.peers

Set up Node 2 -

 $ ./build/bin/geth --datadir data/node2  --port 30305  --networkid 1234 init genesis/genesis.json 
 WARN [11-05|01:08:12] No etherbase set and no accounts found as default 
 INFO [11-05|01:08:12] Allocated cache and file handles         database=/home/rajkumar/Coding/ethereum/go-ethereum/data/node2/geth/chaindata cache=16 handles=16
 INFO [11-05|01:08:12] Successfully wrote genesis state         database=chaindata                                                            hash=a3c5c1…d6926b
 INFO [11-05|01:08:12] Allocated cache and file handles         database=/home/rajkumar/Coding/ethereum/go-ethereum/data/node2/geth/lightchaindata cache=16 handles=16
 INFO [11-05|01:08:12] Successfully wrote genesis state         database=lightchaindata                                                            hash=a3c5c1…d6926b
 [rajkumar@localhost go-ethereum]$ ./build/bin/geth --datadir data/node2  --port 30305  --networkid 1234 console 2>console-node2.log
 Welcome to the Geth JavaScript console!

 instance: Geth/v1.7.1-unstable-0956967e/linux-amd64/go1.9
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

 > admin.nodeInfo
 { enode:"enode://c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329@[::]:30305",


  id: "c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329",
  ip: "::",
  listenAddr: "[::]:30305",
  name: "Geth/v1.7.1-unstable-0956967e/linux-amd64/go1.9",
  ports: {
    discovery: 30305,
    listener: 30305
  },
  protocols: {
    eth: {
      difficulty: 131072,
      genesis: "0xa3c5c170988f516e00ea3078b2461a149bcd4d0422c8c894923c6cfa22d6926b",
      head: "0xa3c5c170988f516e00ea3078b2461a149bcd4d0422c8c894923c6cfa22d6926b",
      network: 1234
    }
  }
}
>

ip configuration of my laptop is -

$ ifconfig|grep netmask|awk '{print $2}'
10.0.2.15
127.0.0.1

Adding node2 to ethereum network -

  >admin.addpeer(enode://c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329@[::]:30305)
 (anonymous): Line 1:20 Unexpected token :

 >admin.addpeer(enode://c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329@localhost:30305)
 (anonymous): Line 1:20 Unexpected token :

 >admin.addpeer(enode://c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329@127.0.0.1:30305)
 (anonymous): Line 1:20 Unexpected token :

 >admin.addpeer(enode://c9b201a3a5e478f059c909b3db1d595e8aa9b3a8ba254eb8830441934ca58f079db8b0bf247d06249a50eafb3372d8d8d5b4df0bf3171530832959279928a329@10.0.2.15:30305)
 (anonymous): Line 1:20 Unexpected token :

As mentioned above, I have tried all combinations of [::], localhost, 127.0.0.1 and 10.0.2.15 which is actual ip config of my laptop but still I'm getting same error in the addpeer command.

Also, I haven't provided --nodiscover option while creating any of the nodes.

Anyone knows the reason for this error?

  • 1
    just to be sure, you execute admin.addpeer() in node1's terminal? – Achala Dissanayake Nov 5 '17 at 7:10
2

geth console it's plain javascript console. It's support javascript syntax, you're missing the quotes " ":

admin.addpeer("enode://c32........9@[::]:30305") 
              ^_______________________________^
  • 1
    your suggestion worked!!! I've accepted your answer!!! – Rajkumar Natarajan Nov 5 '17 at 16:48

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.