In this video, we are going to discuss the new MetaMask Privacy Mode. This came into effect on November 5, 2018, and will be set as mandatory pretty soon.

With this in mind, I will show you the effects of using the old and new method through a side-by-side comparison with individual directories for each method, both installed with web3-0.20.6 and http servers via npm. I will also walk you through on how to update your code to accommodate the new privacy mode by tweaking the index.html files.

Watch the video below for a more detailed instruction on how all these are used to run the old and new method for MetaMask Privacy Mode:

This is a sample code:

window.addEventListener("load", async () => {
  if (window.ethereum) {
    // use MetaMask's provider to get access to the blockchain
    try {
      await window.ethereum.enable(); // get permission to access accounts
      App.web3 = new Web3(window.ethereum);
    } catch(error) {
      console.error(error);
    }
    
  } else {
    console.warn(
      "No web3 detected. Falling back to http://127.0.0.1:9545.",
    );
    //fallback
    App.web3 = new Web3(
      new Web3.providers.HttpProvider("http://127.0.0.1:9545"),
    );
   }
  });

Grab a copy of Thomas Wiener's book here: Ethereum Blockchain Developer
Let's hangout on social media too! Follow me on:
Udemy Courses | Facebook Page | LinkedIn | YouTube