我正在移动 Metamask 应用程序上尝试 Metamask 连接。但我没有得到适当的解决方案。它在 Web 浏览器 Metamask 扩展中运行良好。
以下代码用于 Magento 2 中的 Web 浏览器。但是,不适用于移动应用程序。我也在尝试使用detectEthereumProvider。但是,它也不适用于移动 Metamask。我也使用过Provide window ethereum。但是,它也不起作用。
require([
'jquery',
'Magento_Theme/js/view/messages',
'mage/url',
'web3'
], function($,messages,url,web3){
let accounts;
let contract;
let contractAddress;
const getData = async () => {
var web3 = new Web3(window.ethereum); /* initialize web3 object */
const { ethereum } = window;
var web3 = new Web3(window.ethereum);
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
}
}
getData();
}
);
我也在使用vanilla js,使用钱包连接 Web3model但也无法正常工作。因为,据说 Web3Modal NPM 包必须用于 Web3model 但它可以在 magento 2 上使用?