In the backend of a Web application I have to communicate with the public Ethereum Blockchain.

On local development machine, I run ganache as testrpc and connect with such a line of code:

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

I've also found out that I can develop against Rinkeby testnet with:

web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/$thisistheapikey"));

But how can I communicate with the REAL public Blockchain? Do I need to run geth on the Web server and connect to its instance? Or is there any public network available that could be used (if we can trust it)?

2 Answers 2


Well, Rinkeby is a public testnet, but the chain that holds real Eth that is tethered to real fiat is called Mainnet.

You can connect to it through Infura:

web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/$thisistheapikey"));

On backend you can use an implementation of Web3 library for your backend language of choice. You can also run your own Mainnet node, but it won't change your code apart from the Web3 connection string, e.g.

web3 = new Web3(new Web3.providers.HttpProvider("http://my-mainnet-node.dev.local:8545"));

Pros of having your own geth node is having control over your own environment and it's free of charge under any load, unlike Infura.
Cons of this method include having to manage your own node, expenses on a good server to host your node (you will need a good SSD with large capacity, significant amount of RAM for fast synchronization and a decent processor to process txs and hold under a significant load).

Hope it helps.


I assume that by "REAL" blockchain you mean the mainnet of Ethereum.

There are a few ways to connect to the mainnet of Ethereum. The simplest way to do this is through Infura, as you have above. the only difference is that you would remove the word rinkeby from the url. You should use the following:

web3 = new Web3(new Web3.providers.HttpProvider("https://infura.io/$thisistheapikey"));

This works well and will allow you to perform all that Infura allows you to perform.

In order to not depend on Infura, you would need to run a node. This can be geth, parity, or any other Ethereum node that you choose. This is harder to do than simply relying on Infura, but it will allow you full control over your node interactions.

As a side note, you can run any of the testnets using geth and parity as well by simply setting certain flags.

  • 1
    Thank you very much @Shane. There were two similar answers here and I'm going to accept the answer from Ivan because he has less credits than you :) You both helped me a lot!
    – delete
    Commented May 16, 2019 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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