我试图使用web3将我的webiste连接到testnet,但当我解锁元问询并将元请求连接到testnet时。web3无法连接到元web3。
请帮我解决这个问题。
这是我的代码web3。
web3 = require('web3');
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
console.log("existing web3: provider " + typeof web3);
}
else {
web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/access_token"));
console.log("new provider " + web3);
}错误:提供程序未设置或无效
发布于 2018-04-04 04:29:11
我想你错了一条线
Web3 = require('web3'); // <---- Here you need 'Web3' with 'W'
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
console.log("existing web3: provider " + typeof web3);
} else {
web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/access_token"));
console.log("new provider " + web3);
}https://ethereum.stackexchange.com/questions/44611
复制相似问题