Ethereum Node Connection TypeError Cannot read property version of undefined

0 votes

I have an ethereum node running in my system:

--rpc --rpcaddr "127.0.0.1" --rpcport "8000" --rpccorsdomain "*" --datadir "/home/Sample/Ethereum/Data/node1" --port "30303" --maxpeers 2 --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3,solc" --rpcapi "db,eth,net,web3,personal" --networkid 1900 --nat "any" --unlock "0" --nodiscover console init ~/Ethereum/Data/node1/customgenesis.json

I am trying to connect to this node from nodejs using the following code:

var Web3 = require('web3');
var web3 =Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8000'));
console.log(web3.version.api)

but, I am getting this error

TypeError: Cannot read property 'version' of undefined

Can someone help me solve this issue?

Oct 24, 2018 in Blockchain by slayer
• 29,370 points
1,935 views

1 answer to this question.

0 votes

In the code that you are using to connect to the node, you are missing the new keyword. Your code should be:

var Web3 = require('web3');
var web3 =new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8000'));
console.log(web3.version.api)

This should work..

answered Oct 24, 2018 by Omkar
• 69,220 points

Related Questions In Blockchain

0 votes
0 answers

Cannot read property 'curve' of undefined, while running hyperledger fabric project.

Cannot read property 'curve' of undefined ...READ MORE

Jan 30, 2019 in Blockchain by shraddha
1,603 views
0 votes
0 answers

Azure Blockchain , Cannot read property 'uri' of undefined

I am starting with Azure Blockchain. When ...READ MORE

Apr 4, 2022 in Blockchain by Rahul
• 9,680 points
420 views
0 votes
1 answer

How can i read headers of blockchain in multichain?

You could use a recent feature known ...READ MORE

answered Mar 26, 2018 in Blockchain by Perry
• 17,100 points
737 views
0 votes
1 answer

Connection failed to Ethereum Ropsten Testnet network.

 It looks like your node isn't syncing ...READ MORE

answered Mar 27, 2018 in Blockchain by Christine
• 15,790 points
1,725 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,928 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,456 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,435 views
0 votes
1 answer

Cannot read property 'getBlock' of undefined

getBlock is used by web3 and to use it, ...READ MORE

answered Jan 29, 2019 in Blockchain by Omkar
• 69,220 points
1,565 views
0 votes
1 answer

Blockchain: Installing an earlier version of ethereum using apt-get on

geth does not make the previous version available ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 69,220 points
1,387 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP