StephenGrider / EthereumCasts

Companion repo to an Ethereum/Solidity course on Udemy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please update the web3.js file according new changes ? Unable to get the accounts and other details of contract while using metamask.

elixirautomation opened this issue · comments

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;

add localhost to connections in metamask