I just set up a Block Explorer to interact with my private blockchain.

The private Blockchain runs in a VM. The host system connects to the Block explorer (also on VM).

When I have meta mask installed in my Browser the request fails. See image.

enter image description here

When I uninstall Meta Mask the application can get the Blocks from the Blockchain.

enter image description here

VM - Ubuntu 18.04

HOST - Windows 10

This is a very strange behaviour. What exactly is causing this problem? Especially because I dont even interact with meta mask.

EDIT 1: Although it makes no sense I deactived Privacy Mode on Metamask. However it is still NOT working.

EDIT 2: Same behaviour on firefox.

EDIT 3: Steps to reproduce:

  • Set up a private blockchain.

  • Configure the explorer on the chains RPC-Port.

  • Start Blockchain & Explorer.

  • Now it works.

  • Install MetaMask.

  • Now it doesn't work.

EDIT 4: Code line that are most likely to cause the problem with metamask

In app.js:

var web3 = new Web3();
var eth_node_url = 'http://xxx.xxx.xxx.xxx:22000';
web3.setProvider(new web3.providers.HttpProvider(eth_node_url));

However the programm keeps running and crashes at:

var blockNum = $scope.blockNum = parseInt(web3.eth.blockNumber, 10);

Does MetaMask override the web3 instance I created?

  • This is just a theory but CORS error only occur when a site try to use javascript from an user to get another website data. In this case i think your blockchain explorer is trying to take informations from metamask on the same browser but metamask is not allow. So your blockchain explorer go kaboom because it cannot get any information. Maybe the main reason is because web3.
    – haxerl
    Aug 22 '19 at 9:37
  • You can take a look at the source code here: github.com/etherparty/explorer In my opinion it does not interact with meta mask. Aug 22 '19 at 9:51
  • I think the code connect to the same network on the same port in your localhost with metamask so it got conflict somewhere. Did you try to change the metamask network?
    – haxerl
    Aug 22 '19 at 10:27
  • I use RPC port 22000. I metamask throguh the testnets. Same behaviour Aug 22 '19 at 10:38

I fixed it. Add this code in app.js:

// MetaMask injects its own web3 instance in all pages, override it
// as it might be not compatible with the one used here
if (window.web3)
    window.web3 = web3;
  • Very good, worked for me as well just add it after $rootScope.web3 = web3;
    – felix
    Aug 22 '19 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.