Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught (in promise) Error: Invalid JSON RPC response: undefined #4

Open
tanujajoshi1 opened this issue Sep 13, 2020 · 1 comment
Open

Comments

@tanujajoshi1
Copy link

Screenshot from 2020-09-14 00-37-01

I am getting these error after writing my app.js. My metamask is do connecting, ganache is also open still it is breaking somewhere. Please help me. I am using Ubuntu with latest version of web3 and truffle

@ghost
Copy link

ghost commented Oct 10, 2020

Same issue. But its because you're not using the exact specific versions he is, at least I assume you aren't.

I use the below code for connecting up to metamask, note that I comment out the tx.

loadWeb3: async () => {

        // Modern dapp browsers...
        if (window.ethereum) {

            window.web3 = new Web3(ethereum);
            try {
                // Request account access if needed
                await ethereum.enable();
                // Acccounts now exposed
                //web3.eth.sendTransaction({/* ... */});
            } catch (error) {
                // User denied account access...
            }
        }
        // Legacy dapp browsers...
        else if (window.web3) {
            window.web3 = new Web3(web3.currentProvider);
            // Acccounts always exposed
            //web3.eth.sendTransaction({/* ... */});
        }
        // Non-dapp browsers...
        else {
            console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');
        }

        console.log("done loading web3");

    },

For your load account you will need a different way to get an account

loadAccount: async () =>{

        App.account = web3.eth.defaultAccount;
        console.log(App.account);

    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant