Introduction
The Frontend of any decentralized application or Dapp is more or less the same as in traditional web applications but the Backend, not so much. So in this blog, let's go through the various parts and tools that make up the backend of a decentralized application.
The Blockchain
In the context of a Dapp, a Blockchain is a state machine that allows code to exist in a decentralized manner and lets all the participants of the network agree on the output. The code instead of being hosted on a centralized server exists on multiple machines (nodes) that are participants of the network.
There are numerous Blockchains in this day and age to build on. A few famous ones are Ethereum, Solana, Cardano, Arbitrum, Flow, Filecoin, etc. My favourite right now is Flow because of reasons like having multiple types of nodes for scalability and their resource-oriented programming language, Cadence.
Smart Contracts
A smart contract is a digital agreement that operates on a Blockchain. It functions as the backend code of a dApp, automating and enforcing the terms of the agreement. It acts as a computer program that executes actions based on predefined conditions. Smart contracts eliminate intermediaries, ensuring transparency, security, and trust in dApps. They enable autonomous operations, making them efficient and reliable.
This is an illustration I made that nicely explains the link between a Blockchain and Smart Contracts.
Interacting with the Blockchain
To interact with a Blockchain network, you need to interact with any of the Blockchain nodes and for that, you need to use an RPC Endpoint which basically is a network address used for addressing remote service using the RPC Protocol. There are several ways to do this:
Accessing a public RPC Endpoint - They are provided by the network itself but the drawback is that they are not very stable and hence are not recommended for production.
Running your own nodes - You can also run your own full nodes of the Blockchain network you want to access but it is too a very tiresome process.
Accessing a node provider as a service - There are a handful of services that provide Blockchain nodes as a service. Like Alchemy, Quicknode, Infura, etc. These are called providers. It is one of the most sought out options for developers to access the Blockchain network, the only drawback is that this creates a centralized checkpoint for the Dapp.
Accessing a decentralized node provider as a service - As the name suggests, these are node providers that are decentralized in nature. Ankr and Pokt Network are some examples.
File Storage
Where to store images, videos, and other files in web3?
IPFS - IPFS is a way to store and share files on the internet without relying on a single company or server. It breaks files into smaller pieces and stores them on many computers connected to the network. Each file piece has a unique address, making it easy to find and access files. This decentralized approach makes file sharing more efficient and reliable.
Filecoin - Filecoin is a network where you can buy and sell storage space using a digital currency called Filecoin. Storage providers store your files securely and earn Filecoin tokens. You can retrieve your files anytime by paying with Filecoin tokens. It's a secure and efficient way to store and share files.
Arweave - Arweave is a decentralized storage platform that securely stores web content and applications. It uses blockchain technology to ensure permanent and tamper-proof storage, rewarding participants with AR tokens. It enables long-term availability and supports the development of decentralized applications.
Decentralized database stored off-chain
Decentralized databases stored off-chain are used in building dApps because they make apps faster, keep data private, and give developers more options. They help handle lots of data without slowing down the blockchain. Data is stored securely and users have control over it. Developers can also create more advanced apps with different data structures. Ceramic Network is an example.
Oracles
Oracles are services that connect smart contracts with external data sources. They provide real-world data and external API access to decentralized applications. Oracles validate and verify data before it is used by smart contracts, enabling dApps to interact with and respond to real-world events. They bridge the gap between the blockchain and the off-chain world, enhancing the capabilities of decentralized applications. Chainlink is one of the most famous oracles.
API (For indexing & querying)
Blockchain data is written and replicated in n number of blocks across the blockchain network making anything other than basic read operations impossible. In many applications, we often require features like organizing data, searching, filtering, sorting, and more. To enable these functionalities, data needs to be structured and indexed for efficient and quick retrieval. The Graph is a decentralized protocol that makes indexing and querying blockchain data much easier.
These are the various parts of the backend of a web3 application and some of the most used services for the same. There is a possibility that I might have missed some parts. Feel free to reach out to me to add something to this blog or correct me.
You can refer to this amazing blog by Preethi Kasireddy to understand how the Frontend of a Dapp interacts with the Backend.
Subscribe to my newsletter and follow me on my socials to never miss another blog from me.
Cover Image by storyset on Freepik