EthereumCasts
EthereumCasts copied to clipboard
Please update the web3.js file according new changes ? Unable to get the accounts and other details of contract while using metamask.
Please suggest how to change this code according to new metamask security update.
Metamask Medium Post - New Changes
Now no accounts will be exposed by default and unable to show the account of testnet on UI.
import Web3 from "web3"; let web3; if (typeof window !== "undefined" && typeof window.web3 !== "undefined") { //We are in the browser and metamask is running. web3 = new Web3(window.web3.currentProvider); } else { //We are on ht browser OR the user is not running metamask const provider = new Web3.providers.HttpProvider( "https://rinkeby.infura.io/v3/<Infura_ID>" ); web3 = new Web3(provider); } export default web3;
this should help you fix that problem : https://medium.com/metamask/https-medium-com-metamask-breaking-change-injecting-web3-7722797916a8
add localhost to connections in metamask