使用Nodejs连接到以太坊节点



我有以下以太坊节点运行为:

--rpc --rpcaddr "127.0.0.1" --rpcport "8000" --rpccorsdomain "*" --datadir "/home/mohammad/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

我已经安装了web3从nodejs连接到这个节点如下:

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

但是,我得到这个错误

TypeError: Cannot read property 'version' of undefined

知道为什么会这样吗?

Web3(…

最新更新