1

I have the following ethereum node running as :

sudo geth --rpc --rpcaddr "127.0.0.1" --rpcport "8000" --rpccorsdomain "*" --datadir "/home/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 have installed web3 to connect to this node from nodejs as the following :

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

Any idea why this happens?

3

You forgot the new keyword before Web3(...

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.