我已经成功在以太坊上创建了一个专用网络,该网络运行在8000和8080端口上。我已经使用正常工作的默认地址在node1中部署了一个简单的智能合约。 现在,我尝试将智能合约用于节点2中的地址,但是我的web3实例未初始化。
geth --datadir c:\EthereumTest\ETH\Node1 --networkid 12345 console --rpc --rpcport "8000" --rpcaddr "127.0.0.1" --nodiscover --rpccorsdomain "*" --allow-insecure-unlock --rpcapi "eth,net,web3,miner,debug,personal,rpc
geth --datadir c:\EthereumTest\ETH\Node2 --port 8080 --networkid 12345 --ipcdisable console
节点1:
web3IPC = '\\\\.\\pipe\\geth.ipc';
let web3 = new Web3(web3IPC, net);
web3.eth.getCoinbase(function (err, cba) {
coinbaseAddress = cba;
console.log(coinbaseAddress); //gives valid data
});
节点2:ipcdisabled。如果我不这样做,则会出现拒绝访问错误。在此节点中,我看不到IPC端点
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8080"));
web3.eth.getCoinbase(function (err, cba) {
coinbaseAddress = cba;
console.log(coinbaseAddress); //Gives undefined
});
请建议我如何使用连接到节点2的seocond nodejs应用程序中的web3 rpc合约。另外,如何启动正确的web3实例。