【问题标题】:I want to connect contract without using meta mask我想在不使用元掩码的情况下连接合同
【发布时间】:2021-08-21 12:35:54
【问题描述】:

想为某些人显示合同信息,但不想使用元掩码-在使用元掩码和 web3 之前,它可以工作-现在希望当客户检查我们的网站时(html/java 脚本前端合同)他们从来没有安装元掩码,只需查看从合同加载的信息。请帮帮我。

在我使用此代码之前,但在其他浏览器中人们会看到以太坊的错误:

<script>

            if (typeof window.ethereum !== 'undefined') 
            {
                console.log('MetaMask is installed!');                  
            }else{
                console.log('MetaMask not installed!');
                alert("Please install Metamsk wallet first, then try again");
                 }  
            const accounts = ethereum.request({ method: 'eth_requestAccounts' });
            const account = accounts[0];
            const showAccount = document.querySelector('.showAccount');
</script>

enter image description here

【问题讨论】:

    标签: backend blockchain contract


    【解决方案1】:

    我找到了问题的答案。 我必须从 page 使用 Infura

    请查看information

    首先你必须在infura创建项目并获取ID

    并使用此代码:

    web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/3c68e/*Your Own ID*/1753"));  

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-25
      • 2020-11-01
      • 2021-03-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-02
      • 2020-10-30
      相关资源
      最近更新 更多