I have been using web3 nodejs and infura.io to build apps that interact w/ the Ethereum Blockchain and it is all great but I don't like the idea of a failure point my my apps because they rely on a third party (I.e. infura.io). How does one interact w/ the blockchain without use of a third party, obviously this is possible since infura themselves must be doing it
2 Answers
Infura is basically just running a bunch of nodes to which it provides access for you. So you just need to run your own node.
There are a few different node clients available; the most popular are Geth and Parity. You can choose any client you wish. So just download the client program, read instructions and start synchronizing the node with the blockchain. Once it's fully synchronized you can use it the same way you'd use Infura (and in many other ways as well).
-
1Thanks, "GETH" is a good place for me to start researching. I just needed a term I could put in google to start bringing up more info but was hitting a wall since all the top result blogs are written about using third party APIs, the term 'GETH' is bringing up good results for me. Oct 28, 2019 at 20:50
-
2You can use your own node with extended API compared to Infura, like for instance managing your own wallets via the
personal
RPC API, which IMO is a very important difference worth mentioning. Oct 28, 2019 at 21:22
If your goal is to eliminate single points of failure in your system, you need to study how peer to peer applications like geth achieve resilience.
Replacing infura by a node that you own and control is a good first step as infura is used by a lot of dapps and could be the target of an attack to take dapps down. However, by doing this, you're simply replacing a point of failure by another.
What geth does during the peer discovery phase is connecting to a list of trusted bootnodes. These bootnodes can inform your geth node about the addresses of other nodes. This way you end up with a list of peers to sync from.
If a node falls, there are plenty of other nodes to relay the informations, and the network can continue to operate. If all the trusted bootnodes fall, the network stops functioning.
Now how to achieve the same level of resilience in a dapp? If your app runs in the browser, it's not going to be easy. The technology is simply not mature enough to do the same kind of peer discovery in javascript. The idea is to have what we call a light client. This kind of client can discover peers like geth does, but won't try to synchronise the gigabytes of data needed to operate. These things are still in development.
If your app is a desktop app, you can embed a geth node in your app like AKASHA did.
-
Application runs in C and/or JS. Is there any reason you need a geth node to broadcast to the network, or can I just use a pre-determined massive list of trusted nodes and it broadcasts iteratively until one succeeds Nov 4, 2019 at 14:50
-
1You could broadcast your transactions to a list of infura-like RPC endpoints yes. They usually expose a subset of the API that is enough to do everyday tasks. You will notice that there are not a lot of these public endpoints however. We call these RPC endpoint providers Blockchain as a Service. See Cloudflare, Infura, Chainstack, BlockCypher, and BlockForm (my own). The problem with this is that wallets like MetaMask don't support falling back to backup RPC endpoints. They are working instead on implementing light clients, which will be the clean way of solving the problem.– KivutarNov 5, 2019 at 1:59
-
I already use infura, I could use a list of various services that offer said enpoints but I'd rather just directly broadcast the transaction myself without relying on a third party. Nov 5, 2019 at 2:34
-
2To directly broadcast, without a relay / single point of failure, you need the p2p stack that ethereum nodes use. The quickest way would be to embed a light ethereum client (like geth in light sync mode).– KivutarNov 5, 2019 at 3:05
-