GithubHelp home page GithubHelp logo

Comments (4)

chainmonky avatar chainmonky commented on July 17, 2024 2

yes this worked

from ethereumcasts.

chainmonky avatar chainmonky commented on July 17, 2024

I am getting the same error too @StephenGrider. I'm using beta-37 version @Kartik-Ganiga are you able to sort this out ?

from ethereumcasts.

0xKartik-dev avatar 0xKartik-dev commented on July 17, 2024

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!

from ethereumcasts.

0xKartik-dev avatar 0xKartik-dev commented on July 17, 2024

I am closing this issue .

from ethereumcasts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.