title: How to connect MetaMask with Web3.js version 1.2.6?
body: <p>I have written a smart contract (deployed on Ropsten) and a website (node.js, express.js and ejs)</p>
  
  <p>I can read data from the contract with Infura API and shown on the web page successfully. However, I want to write data on the contract through Metamask.
  Currently. I cannot connect MetaMask with web3.js 1.2.6. I have checked Web3.givenProvider return null also.</p>
  
  <p>(I can interactive with my smart contract through MyEtherWallet + Meta Mask)</p>
  
  <p>Detail information: </p>
  
  <p>Development envrionment: node.js express.js ejs web3.js(1.2.6)</p>
  
  <p>Browser: chrome + MetaMask: localhost:3000 / 127.0.0.1:3000</p>
  
  <pre><code>const express = require('express');
  const router = express.Router();
  
  const Web3 = require('web3');
  //const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/xxxxxxxx"));
  const web3 = new Web3(Web3.givenProvider);
  
  const Tx = require('ethereumjs-tx');
  
  let myAddress = '0x3E0980E7cea6804B01BEA49cb70F9B7Cxxxxxxxx';
  const abi = [***VERY LONG ABI***];
  const address = "0x07cf2ecef130495ea18a25e4f1dfbfc4xxxxxxxx";
  const MyContract = new web3.eth.Contract(abi, address);
  
  // define the home page route
  router.get('/', (req, res, next) =&gt; {
      const resultHome = [];
  
      MyContract.methods.name().call().then((name) =&gt; {
          resultHome.push(name);
          symbol();
      })
      const symbol = () =&gt; {
          MyContract.methods.symbol().call().then((symbol) =&gt; {
              resultHome.push(symbol);
              totalSupply();
          })
      }
      const totalSupply = () =&gt; {
          MyContract.methods.totalSupply().call().then((totalSupply) =&gt; {
              resultHome.push(totalSupply);
              home();
          })
      }
  
      const home = () =&gt; {
          res.render('erc20/index', {
              pageTitle: 'ERC-20E Token Standard Enhanced - Info',
              path: 'erc20',
              subPath: 'erc20Info',
              name: resultHome[0],
              symbol: resultHome[1],
              address: address,
              totalSupply: resultHome[2] / 100
          })
      }
  })
  
  router.get('/source', (req, res, next) =&gt; {
      res.sendFile(__dirname + '/erc20Source.txt');
  })
  
  // define the controller route
  router.get('/controller', (req, res, next) =&gt; {
      let resultController = [];
  
      MyContract.methods.showRun().call().then((showRun) =&gt; {
          resultController.push(showRun);
          controller();
      })
  
      const controller = () =&gt; {
          res.render('erc20/controller', {
              pageTitle: 'ERC-20E Token Standard Enhanced - Controller',
              path: 'erc20',
              subPath: 'erc20Controller',
              showRun: resultController[0]
          })
      }
  })
  
  module.exports = router;
  </code></pre>