Traditional vs Onchain Architecture
- Traditional Stack
- Onchain as an Additional Layer
- Frontend: Usually React, Vue, or another framework
- Backend: Node.js, Python, or similar, handling business logic
- Database: A solution like Postgres or MongoDB for persistent storage
Integrating a blockchain doesn’t necessarily replace your database or your entire backend. Instead, it augments your stack. For instance, some business logic might remain in your backend, and sensitive data may remain in a traditional database.
What belongs onchain?
Onchain State
Onchain state has several notable properties:Immutable: Once recorded, data can’t be deleted ensuring a permanent historical record
Transparent: All data is publicly viewable and verifiable
Global: Data is stored across multiple nodes, eliminating single points of failure
Onchain Events
Events are triggered when an onchain method is called. Events can have different data formats. In order to make sure events follow the format we are looking to receive on the frontend, we often use data indexers. For that, you can build your own indexer or use one of the existing tools.Onchain Logic
Onchain logic is stored in smart contracts. Similar to onchain data, it is immutable, transparent, and global. By default, onchain logic is accessible to every network participant, but can be permissioned so that only certain participants can interact. This makes onchain logic highly composable where builders can leverage existing onchain logic and extend that logic in novel ways instead of building from scratch.Capabilities: Transfer funds and digital assets, create onchain games, create content and social posts onchain, and more. Pretty much anything you can do offchain can be done onchain.
If you have proprietary logic which you don’t want public, this shouldn’t be onchain. Or if the logic doesn’t need to be decentralized and is computationally expensive, it may be better kept in a traditional backend opposed to onchain.