Traditional vs Onchain Architecture
- 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
Expensive: Storing data onchain is expensive because it must be stored by every node globally
Onchain Events
Since storing data onchain is expensive, we oftentimes use a cheaper alternative: events. Events are not part of the state, which makes them optional to store when running a node. They are a lot cheaper to use than state storage.
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.
Cost Consideration: Because every node in the network needs to execute every transaction, each transaction has a cost dependent on the computational expense of the onchain logic being run in that transaction.
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.