As we know, metamask will no longer inject web3.js starting Jan 13, 2020. What are the approaches we should take to stop the dependency on web3?
Also how can we test it out with the existing Metamask that is injecting web3.js as of now.
As we know, metamask will no longer inject web3.js starting Jan 13, 2020. What are the approaches we should take to stop the dependency on web3?
Also how can we test it out with the existing Metamask that is injecting web3.js as of now.
window.ethereum
will still contain Web3 Provider. You can use it setup your web3 convenience library of choice such as web3.js or ethers.js. For example:
const Web3 = require('web3');
// web3 lib instance
const web3 = new Web3(window.ethereum);
// get all accounts
const accounts = await web3.eth.getAccounts();
import Web3 from "web3";
let web3;
const ethEnabled = async () => {
if (window.ethereum) {
web3 = new Web3(window.ethereum);
await window.ethereum.enable();
}
}
ethEnabled();
export default web3;
© 2022 - 2024 — McMap. All rights reserved.