0

I have a html code interacting with my smart contract via a local test rpc local host.

I was just wondering if I deploy this contract to the main network instead of using test rpc, what should be the http provider I specify in my html code?

As well as would the user whom will interact with the html page need to have a test rpc running as well.

   <script>
   if (typeof web3 !== 'undefined' && typeof window.web3.currentProvider !== "undefined")
   {
     console.log(typeof web3)
     web3 = new Web3(web3.currentProvider );
   } else {
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
   }
0

In case where your machine (node) is connected to the main network you can keep the local http provider (localhost:8545). Otherwise you can use an online http provider as infura servers.

As well as would the user whom will interact with the html page need to have a test rpc running as well.

testrpc is just for testing purposes (running a local blockchain like localhost) so users either use their nodes connected to main network (which is not practical i guess) or you use infura or other online nodes which connect them directly to the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.