Open KrishnaVeer7712 opened 4 years ago
window.ethereum.enable();
after line 16(web3 = new Web3(web3.currentProvider);
) in \src\js\app.js
fileEven after adding window.ethereum.enable()
im getting the same Page with 'Loading....'
I'm getting the same error. Please help somebody!
Please update function initWeb3
in the app.js
with the following:
initWeb3: function() {
if (typeof web3 !== 'undefined') {
// If a web3 instance is already provided by Meta Mask.
const ethEnabled = () => {
if (window.ethereum) {
window.web3 = new Web3(window.ethereum);
window.ethereum.enable();
return true;
}
return false;
}
if (!ethEnabled()) {
alert("Please install an Ethereum-compatible browser or extension like MetaMask to use this dApp!");
}
web3 = window.web3;
App.web3Provider = web3.currentProvider;
} else {
// Specify default instance if no web3 instance provided
App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
web3 = new Web3(App.web3Provider);
}
return App.initContract();
},
@vasvi-sood could you please try my solution?
It is working with your code thanks. But the actual problem was that I needed to refresh the page, because metamask didn't connect automatically.
Thanks!
when I enable MetaMask in crome and setup to required accounts, localhost web page is showing loading evin i had properly setup MetaMask as shown in image.
But when I dissabled the MetaMask, It is showing proper output with account at index 0 as shown below: truffle version Truffle v5.1.26 (core: 5.1.26) Solidity - 0.4.25 (solc-js) Node v12.13.0 Web3.js v1.2.1 Please help me getting out of this.