我在这里读到了其他类似的问题,但都没有解决我的问题。我有一个终端机窗口,我在上面运行
geth --networkid=4 --rpc --rpcport 8545 --datadir=$HOME/.rinkeby --syncmode=light --ethstats='yournode:Respect my authoritah!@stats.rinkeby.io' --bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303?discport=30304基于测试链林克比的connect您自己部分。
我还有一个节点应用程序
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));我是在发射geth之后跑的。
终端不带任何问题启动geth,并输出INFO [07-12|15:40:40] HTTP endpoint opened: http://127.0.0.1:8545。我不明白为什么我的节点应用程序在连接上有困难。
错误是ReferenceError: web3 is not defined。
发布于 2017-07-13 05:36:03
我已经发动了
geth -networkid=4-datadir=$HOME/..rinkeby syncmode=light --bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4e4aa13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303?discport=30304 -rpcapi=eth,web3,net,personal,ssh,db,调试控制台
并让这个测试文件index.js
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log(web3.eth.blockNumber);并且它将在执行node index.js时输出当前块。
https://ethereum.stackexchange.com/questions/21081
复制相似问题