Ethereum 我很难在前端调用合同方法

Ethereum 我很难在前端调用合同方法,ethereum,solidity,web3,web3js,Ethereum,Solidity,Web3,Web3js,我想从浏览器本身调用我的合同,所以我使用了Metamask,它可以无缝工作,但我不想使用Metamask,因为Metamask不能在手机中使用 我使用了metamask,它可以工作 我在后端使用了trufflehdwallet,效果很好 我使用了testrpc网络,它也可以工作 if (window.ethereum) { window.web3 = new Web3(ethereum); try { // Request account

我想从浏览器本身调用我的合同,所以我使用了Metamask,它可以无缝工作,但我不想使用Metamask,因为Metamask不能在手机中使用

我使用了metamask,它可以工作 我在后端使用了trufflehdwallet,效果很好 我使用了testrpc网络,它也可以工作

if (window.ethereum) {
        window.web3 = new Web3(ethereum);
        try {
            // Request account access if needed
            await ethereum.enable();

            web3.eth.getAccounts(function (err, accounts) {
                if (!err) {
                    get_contract();
                }
            })

        } catch (error) {
            // User denied account access...
        }
    }
    // Legacy dapp browsers...
    else if (window.web3) {
        window.web3 = new Web3(web3.currentProvider);

        web3.eth.getAccounts(function (err, accounts) {
            if (!err) {
                get_contract();
            }
        })
    }
    // Non-dapp browsers...
    else {
        console.log('Non-Ethereum browser detected. You should consider installing MetaMask !');
    }
我想要这样的东西

web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/24b7104373aa4038a2d0b64d9d60bd85"));

实际上,我认为你的问题与标题不同。 从您的问题中,我了解到您希望在智能手机上使用web dapp

好吧,如果这是问题的话,我有几个选择给你。首先,如果你使用的是mainnet,你会有一些移动应用,比如或。如果您使用的是testnets,则有一个名为的新钱包,允许您连接到公共testnets。老实说,我不建议您测试本地网络,因为它是一个web dapp,您可以使用metamask在笔记本电脑上进行测试

所以,我最后的提示是。这允许用户选择他的钱包