Giter VIP home page Giter VIP logo

Comments (7)

ullahwasim avatar ullahwasim commented on August 15, 2024 3
  1. Add window.ethereum.enable(); after line 16(web3 = new Web3(web3.currentProvider);) in \src\js\app.js file
  2. Connect Metamask.
  3. Refresh Page

from election.

introkun avatar introkun commented on August 15, 2024 3

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();
  },

from election.

Maniddarky avatar Maniddarky commented on August 15, 2024

Even after adding window.ethereum.enable() im getting the same Page with 'Loading....'

from election.

vasvi-sood avatar vasvi-sood commented on August 15, 2024

I'm getting the same error. Please help somebody!

from election.

introkun avatar introkun commented on August 15, 2024

@vasvi-sood could you please try my solution?

from election.

vasvi-sood avatar vasvi-sood commented on August 15, 2024

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.

from election.

gc2000 avatar gc2000 commented on August 15, 2024

Thanks!

from election.

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.