为什么我在写连接,metamask钱包的时候这样写会报错:
if (typeof window.ethereum !== 'undefined') {
// 请求用户授权连接
const web3 = new Web3(window.ethereum);
window.ethereum.request({ method: 'eth_requestAccounts' });
} else {
console.error('MetaMask not installed');
}
这是我的报错:
inpage.js:1
MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3
get @ inpage.js:1
Uncaught TypeError: Cannot read properties of undefined (reading 'Contract')
at index.html:122:35