I am attempting to connect the frontend of an application to a private chain through Metamask.
As no web3 is injected, the following code is run
const getWeb3 = () => ...
... ... ...
const provider = new Web3.providers.HttpProvider("http://127.0.0.1:30303");
const web3 = new Web3(provider);
resolve(web3);
initWeb3 = async () => {
try {
this.web3 = await getWeb3();
this.accounts = await this.web3.eth.getAccounts();
} catch (err) {
alert('Failed to load web3, accounts, or contract');
console.error(err);
}
}
If I put a console.log()
statement after the call to web3.eth.getAccounts()
it never gets called, which to me means that the await
statement never resolves. What could be causing this? The code runs when interacting with a truffle testnet; but, I cannot get it to run with the private chain..