DEV Community

Cover image for Reading from "blockchain" - how it exactly works?
Przemysław Thomann
Przemysław Thomann

Posted on

Reading from "blockchain" - how it exactly works?

Blockchain "engineering" has a lot illusions. Are you building a dapp? Is your client application reading data from blockchain? Do you think it's decentralized? Unfortunately not.

For some it's still a biggest misconception about "decentralized applications/DAPPs" engineering - "reading data from blockchain". We build apps which are decentralized, because they operate with blockchain and smart contracts. In the same time the path, route, infrastructure between user (and his client like Internet browser) and blockchain in most cases is based on centralized infrastructure provider. Should we call it decentralized apps then?

How it works exactly? Whenever you enter the DAPP (web page) which reads data from the blockchain - it reads it from a blockchain node, through a provider. Does it mean that DAPP creators operate a node and integrated a provider in their DAPP (web page)? In some cases yes but mostly not. So how is it possible that it all works?

The magic behind it is something you have probably installed in your browser - MetaMask (or other wallet extension like Rabby). These wallets maintain blockchain nodes on their servers + inject a provider to DAPP (web page) so it can communicate with blockchain. That's the whole magic.

Now, what if you design a DAPP which should work even if user doesn't have Metamask installed? It's a problem - because you have to create your own provider for you DAPP. How? It's easy if you have your own blockchain node. But cmon, who runs own Ethereum blockchain node? Unfortunately almost none - we use service providers like Alchemy , QuickNode , Moralis , etc. which allows to easily connect to their nodes + have a lot of nice SDK to use (like showing all collections NFTs, etc.). So to summary - is it enough to register in any web3 service providers, get access to web3 provider full node on my DAPP web page and it should work? Unfortunately not really.

Why? Web3 service providers are paid (except free tier), what means that you pay for the service. You get unique, private API KEY to use which you don't want to expose public. It means that in your DAPP architecture, your client (webcpage) should connect to your backend service, which then connects to web3 service provider. This creates 2 centralized dependencies: your backend service infrastructure + web3 provider.

Can this be solved somehow to be truly decentralized? Best architecture: every user has a wallet extension connected to his self hosted full node. That's the Bitcoin spirit. Unfortunately impossible scenario for Ethereum (too heavy node). To design a DAPP which doesn't require users to have Metamask for reading data from blockchain, you could maintain own full node, so you eliminate described above web3 provider. It would eliminate 1 centralized provider from the architecture - web3 provider service company. But for most startups + companies it's also not a case. Most use and will use providers due to lower costs (especially at the beginning).

Is it all bad? Bitcoiners will say that yes, that's sux. As a Bitcoiner I agree from "Bitcoiners point of view" but as a EVM builder & DLT architect I will say that in the end we read data from blockchain and it's the clue. Still I believe it's important that there is kind of illusion in that space and architecture which is important to be aware of - especially for not deeply tech involved people.

Follow me on Twitter: https://twitter.com/mobycrypt_com

Top comments (0)