Closed 0xKartik-dev closed 5 years ago
I am getting the same error too @StephenGrider. I'm using beta-37 version @Kartik-Ganiga are you able to sort this out ?
I too got the same problem while working on a DApp with Rinkeby testnet with Metamask.
When i had my web3.js file as below
import Web3 from 'web3';
let web3;
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
// We are in the browser and metamask is running.
web3 = new Web3(window.web3.currentProvider);
} else {
// We are on the server *OR* the user is not running metamask
const provider = new Web3.providers.HttpProvider(
'Infura API key'
);
web3 = new Web3(provider);
//window.web3.currentProvider.enable();
}
export default web3;
and when i run npm start
or npm run dev
( depends on your start script)
The browser was throwing error saying "uncaught error: No 'from' address specified "
When i opened up the browser console and did web.currentProvider
it threw the same error. So one thing got clear that Metamask is not making contact with browser.
What i did is
I kept the Browser on with Metamask logged in. And changed the web3.js to while the server running on command prompt and saved the file.
import Web3 from 'web3';
let web3;
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
// We are in the browser and metamask is running.
//Note: change to window.web3.currentProvider.enable()
web3 = new Web3(window.web3.currentProvider.enable());
} else {
// We are on the server *OR* the user is not running metamask
const provider = new Web3.providers.HttpProvider(
'Infura API'
);
web3 = new Web3(provider);
//window.web3.currentProvider.enable();
}
export default web3;
As soon as you save the file The Metamask throws you an prompt saying it want to make connection from your account.
Click yes.
and remove the .enable() from the above code and save your code.
This can be a temporary solution, but yes it works!
yes this worked
I am closing this issue .
web3 version : web3@1.0.0-beta.26 and tried with beta-35 and beta-51 too. When i click create campaign with soe wei, it throws error ! @StephenGrider