Filter by category:

Knowledge hub home

A pinch of blockchain: partially decentralising an app

Partially decentralising you App

A DApp (Decentralised App) is an app that connects in some way to a blockchain (decentralised network). This doesn’t mean that the entire app is decentralised. Typically it involves just a small component of the app connecting to the blockchain through a straightforward API. 

In fact, most DApps have components that rely on centralised services. For example, they could be storing sensitive information server-side, running computation or serving front end resources on a centralised server. It’s rare that apps are completely decentralised. Partial decentralisation, where an app makes use of blockchain functionality for a single aspect of its service, is far more common.

 

To centralise or to decentralise…

So what are the benefits of decentralisation vs centralisation?

 

A case for centralisation

  • Control: Centralisation gives control to the owner of the software or data. There are legal requirements for one entity to be responsible for making particular decisions. 
  • Efficiency in coordination: Centralisation tends to lead to faster decisions, as there is a single entity responsible for decision making.

 

A case for decentralisation

  • Resilience: Decentralisation means no single point of failure. Once a DApp is deployed, it lives on the network and becomes available to everyone. 
  • Transparency:  All transactions on a decentralised network can be verified by anyone at any time. 
  • Data integrity: The data stored on a decentralised network are kept securely forever and can’t be modified. 
  • Privacy: No more data monopolists capitalising on owning everyone’s data!

 

Partially decentralising – the best of both worlds

As long as your software design follows the principle of separation of concerns, it is possible to create a modular design where some components are centralised, and some are decentralised.

A partially decentralised app allows you to access the benefits of both decentralisation and centralisation; though the decentralised aspects will only apply specifically to the data stored on the chain. It means that app services such as voting, NFT tokenisation or verifiable game transactions, which are easier to execute with a blockchain, can be decentralised while the rest of the apps function runs on a centralised server. 

 

Familiarising yourself with decentralised architectures

A decentralised design can make your app more scalable and easier to maintain.

Here are some concepts that are often used in fully or partially decentralised designs. Note that these designs aren’t mutually exclusive and are often used in combination. 

 

1.The Jamstack architecture

Jamstack stands for JavaScript, APIs, Markup. It has a wide range of applications, including e-commerce sites, SaaS applications and personal blogs. 

Jamstack means pre-rendered content is served via a CDN (Content Delivery Network), and the dynamic features are added through APIs. Pre-rendering makes your web apps very fast to load and removes the need for the server to render the page on every request. 

Some popular Jamstack frameworks include Next.js, Hugo, Gatsby, and Jekyll. Jamstack replaces a traditional web stack which typically involves a web server, an app server, a database, and a CMS, with a simpler design. This makes it easier to maintain and scale.

CENNZnet provides a JavaScript API, which can be used to enhance any Jamstack application.

 

2. The serverless architecture

The serverless architecture typically means the server-side logic is in stateless containers triggered by events. This is achieved by using microservices and stateless functions. Cloud services, such as AWS Lambda, Azure Functions, and Google Cloud Functions, will execute your functions by dynamically allocating resources upon the triggering events. This allows the developer to outsource the infrastructure management.

 

3. Decentralised storage

Decentralised storage such as IPFS (InterPlanetary File System) allows you to share data across a decentralized network. This means you can host your DApp in a peer-to-peer distributed network, which makes it more resilient and inexpensive.

IPFS offers several APIs and a command-line interface, so it can easily be integrated into your DApp.

 

How does a DApp interact with a blockchain?

To interact with a blockchain network, you can either use a public node or set up a private one that’s dedicated to handling the requests from your apps.

 

Public nodes

Interacting with the blockchain through public nodes is easy. On CENNZnet, anyone can connect to our MainNet through a public WebSocket endpoint: wss://cennznet.unfrastructure.io/public/ws

Once you are connected to a public node, you can send signed transactions from your DApp to the node to read and write data from the blockchain.

Learn about the CENNZnet networks and public endpoints here.

Public node access to blockchain

 

Private nodes

For the best results, you can set up your own node. This allows you to control the uptime of the node and optimise the network communication time between your DApp and your node.

In addition, your node can earn rewards by participating in staking as a validator. See the Validator Guide for instructions.

Private node access to blockchain

 

For more details, please refer to the How to build a DApp guide.