Search code examples
backendblockchaincontract

I want to connect contract without using meta mask


want to show contract information for some people but don't want to use meta mask-before used meta mask and web3 and it work-now want when customer check our site(html/java scrips Front end for contract) they never install meta mask and just look at information that load from contract. please help me.

before i used this code but in the other browser people see error for ethereum :

<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


Solution

  • I found the answers to my questions. I Have to Use Infura from this page

    please check this information

    and at first You have to create project in infura and get ID

    and use this code :

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