node.js中使用
import detectEthereumProvider from '@metamask/detect-provider'
const provider = detectEthereumProvider();
if (provider) {
console.log('Ethereum successfully detected!')
} else {
// if the provider is not detected, detectEthereumProvider resolves to null
console.error('Please install MetaMask!')
}
使用之前需要npm install @metamask/detect-provider