Blockchain Fundamentals
If you can't explain it to a six year old, you don't understand it yourself."
(Tahim, G.S., mathematician (1986))
This document provides an overview of the fundamental aspects of blockchain technology. It explains what blockchain is, what it offers, the technological stacks available for developing blockchain solutions, and the core concepts involved. It serves as an entry point into the world of blockchain. Please note that this is not a detailed learning resource for beginners, but rather a brief general introduction.
General
In general the blockchain technology is a decentralized database that organizes transactions or datasets into blocks and connects these blocks together to create a permanent and unchangeable record. Each block contains a group of transactions and a unique identifier of the previous block. This structure creates a cryptographically secure and transparent sequence of information that is verified and stored by a distributed network of computers. One of the key innovations of blockchain is that it does not require a central authority to validate or verify transactions. Instead, confirmation is done through a consensus protocol where the majority of participants in the network must agree that a transaction is legitimate. This decentralized and transparent model makes the blockchain resistant to manipulations, frauds and downtimes.
In addition to this blockchain specific approaches, there are various other decentralized technologies that are used in different areas to improve security, transparency and efficiency ob blockchain systems. (Peer-to-peer (P2P) network, Distributed Hash Tables (DHT), InterPlanetary File System (IPFS), PubSub protocols (Publish/Subscribe), Federated Learning, etc.) Many of these decentralized technologies mentioned are used to extend and improve the functionality and efficiency of blockchain systems. The perception that the blockchain technology is a collection or set of other decentralized technologies is in some ways true, as blockchain integrates concepts and techniques from various areas of cryptography, computer science and networking. Blockchain technology builds on the foundations of decentralized systems, but uses specific mechanisms to enable its unique functionalities.
The term blockchain, as well as other terms from the Web3 sphere, are very often misunderstood and misinterpreted.
The first step is to distinguish the difference between Web3
, Blockchain
and Bitcoin
, as these terms have been widely heard by the majority.
-
Web3: Web3 represents the next evolution of the Internet. It builds on decentralized networks to create an open and accessible online environment where applications and services work without third-party authorities.
-
Blockchain: Blockchain is a decentralized technology that records transactions securely and immutably into a chain of blocks. It enables the transparent and tamper-proof storage of data without a central authority.
-
Bitcoin: Bitcoin is a digital currency (cryptocurrency) based on blockchain technology (1.0) and is the first concept for decentralized finance (DeFi) within the Web3 world. Despite its pioneering role for DeFi, Bitcoin is considered technologically outdated as it has many limits and high energy consumption compared to newer DeFi systems.
In essence, Web3 is the new stage of the internet where the blockchain technology can be used to provide decentralized solutions like Bitcon was. DeFi was the first application area of blockchain technology, but not long after, blockchain technology found other areas that are more technology than finance oriented. Here are just a few: Self-executing contracts with predefined conditions, supply chain management, digital identities, voting and elections, NFTs (Non-Fungible Tokens), healthcare etc.
The State Machine
A state machine is a model that describes a system through various states in which it can exist; the system transitions between these states based on inputs or events, with each state change governed by a defined rule, called a transition.
In a blockchain, the state machine represents the current state of the network, which is influenced by a series of transactions that are stored in a Block. Every Block that occurs on the blockchain results in a transition from one state to the next, with these transitions being defined by the established rules of the network. Since the blockchain is decentralized and immutable, the state is cryptographically secured and stored in the chain with each new block. This ensures that the state remains consistent and tamper-proof, as every change is transparent and traceable. The state machine thus plays a central role in the blockchain, providing the mechanism that ensures the integrity and transparency of the network.
In a blockchain, the state machine is a mechanism that updates the global state of the network after each block is added. Here’s a formal representation:
- State (s): Each state s represents the global state of the blockchain at a specific point in time, encompassing all stored data, such as account balances, contract data, etc.
- Block (B): A block B is a collection of transactions that have been validated and added to the blockchain within a certain time period.
- State Transition Function (δ): The state transition function δ defines how the state of the blockchain changes when a new block is added.
Here, s is the current state of the blockchain, B is the new block, and s' is the new state after the block is processed.
- Initial State (s₀): The initial state s₀ is the state of the blockchain before any blocks are added, typically the state at the Genesis block.
| | ...
OR
Blockchain Frameworks and SDKs
There are several blockchain frameworks and SDKs that have evolved over time, supporting different platforms and approaches. Each of these technologies has its own specific features, advantages, and use cases. Here are some widely recognized examples:
-
Ethereum: Ethereum's technology stack provides a robust development environment for building smart contracts and decentralized applications (dApps), centered around the Ethereum Virtual Machine (EVM) and supported by its native programming language, Solidity.
-
Substrate/Polkadot-SDK: Substrate is a modular framework developed by Parity Technologies in the Rust programming language, designed to simplify the creation of customized blockchains for specific requirements. Its highly modular architecture, combined with the use of WebAssembly (WASM), allows for easy customization and seamless, forkless upgrades, ensuring that blockchains can be updated and adapted without the need for disruptive hard forks.
-
Cosmos SDK: Cosmos SDK is a highly modular framework developed in the Go programming language, designed for building scalable and interoperable blockchain applications. It facilitates the creation of independent blockchains that can seamlessly interact with each other through the Inter-Blockchain Communication (IBC) protocol, enabling the vision of an 'Internet of Blockchains.' The SDK's flexibility and modularity make it easy to customize and optimize blockchains for specific use cases.
-
Hyperledger Fabric: Hyperledger Fabric is an enterprise-grade blockchain framework hosted by the Linux Foundation, designed with a highly modular architecture to support diverse business use cases. Developed primarily in Go, Fabric enables the creation of permissioned blockchains with configurable consensus mechanisms, providing high performance, scalability, and robust privacy features. Its pluggable components allow for customization, ensuring that enterprises can tailor the blockchain to meet specific requirements while maintaining strong data privacy and control.
In addition to the major frameworks, there are several other that allow for the creation of custom blockchains. Hyperledger Sawtooth provides a modular architecture that supports the development of customized blockchain solutions with various consensus options. Quorum, originally developed by J.P. Morgan, is a blockchain framework based on Ethereum, tailored for private and permissioned networks with enhanced privacy features and customizable consensus mechanisms. EOSIO offers a highly scalable framework for building performant blockchains using Delegated Proof of Stake (DPoS), making it suitable for applications requiring high transaction throughput. Multichain is another framework that allows enterprises to deploy private and permissioned blockchains with extensive configurability. These frameworks provide developers with the tools to build customized and interoperable blockchains tailored to various use cases.
Frameworks Cosmos SDK, Substrate/Polkadot-SDK, Hyperledger Fabric, etc. provide developers with the tools to build fully independent blockchains from the ground up. These frameworks or blockchain-SDKs are modular and allow for the implementation of specific features and rules to create customized blockchains for various use cases. In contrast, platforms like Solana, Cardano, Tezos, etc. also offer development environments and SDKs, but these are primarily designed for building applications such as smart contracts and dApps within their existing networks. While a framework/blockchain-SDKs allows you to create your own blockchain with its own infrastructure, using a platform's SDK is limited to developing within that platform's existing network, without the ability to create an independent blockchain.
There are numerous platform-specific SDKs available for developers who wish to build directly on existing blockchain infrastructures without creating their own networks. Examples include Platforms like Solana, Tezos, Cardano, NEO, Binance Smart Chain, Avalanche, Algorand, etc. These platforms provide specialized development environments and tools tailored for building smart contracts and decentralized applications (dApps) within their respective ecosystems. While these SDKs offer robust and efficient solutions for application development, they are designed to operate exclusively within the framework of their underlying platforms, offering streamlined integration but without the need to establish standalone blockchain infrastructures.
Blockchain Networks and its Infrastructure
Blockchain technology enables the creation of blockchain networks, which serve as the foundation of Web3. These networks consist of distributed nodes, each containing identical data. Consequently, every node in the network embodies both the "infrastructure" and the "application" component. However, these nodes do not function independently; instead, they operate collaboratively, continuously verifying each other's data to ensure that all recorded information on the blockchain is accurate and agreed upon by the network.
When new information is to be added to the blockchain (the 'blockchain application'), which can be regarded as the 'application layer,' all nodes (constituting the 'infrastructure layer') must reach a consensus and manage the networking, computing, and storage functions.
In the context of Substrate, this distinction is particularly evident. The Substrate client is responsible for the "infrastructure component," while the runtime handles the "application logic." Thus, a blockchain node in this system encompasses both the infrastructure and application components. This contrasts with the traditional Web2 approach, where infrastructure, databases, and applications are treated as separate entities.
In summary, a blockchain network consists of many distributed nodes that perform various tasks to manage the network. These blockchain nodes, which handle specific tasks, typically contain the same data as other nodes within the network. Consequently, each blockchain node functions as an all-in-one unit: it manages core infrastructure tasks such as data storage, data processing, and acts as both a database and the execution logic. For example, unlike a Web2 application that accesses an external database, in a blockchain, the database is "integrated" within the same node. This is a general example to help understand how blockchain infrastructure operates. When developing dApps (mostly smart contracts), this abstraction can be confusing and should only be used in the context of infrastructure comparison.
Blockchain Layers
In the blockchain world, there are different layers, known as Layer 0 (L0), Layer 1 (L1), Layer 2 (L2), and Layer 3 (L3), each of which provides a distinct technology stack.
-
Layer 0 (L0): This is the base layer or foundation on which other blockchain networks can be built. It forms the basic network and communication infrastructure that enables different blockchain protocols to interact with each other. Layer 0 typically includes technologies and protocols that promote interoperability and shared security between different blockchains. Examples include Polkadot's relay chain and Cosmos's Inter-Blockchain Communication (IBC) protocol, which act as a foundation for connecting multiple Layer 1 blockchains.
-
Layer 1 (L1): This is the core blockchain protocol that forms the main network. There are two scenarios within Layer 1:
- Standalone Layer-1: These are independent blockchains that handle their own consensus, security, and smart contract execution. Examples include Ethereum and Bitcoin, which do not rely on a Layer 0 infrastructure.
- Layer-1 built on Layer-0: In this context, Layer 1 blockchains, such as parachains in Polkadot or zones in Cosmos, leverage the underlying Layer 0 infrastructure for shared security, interoperability, and consensus. Polkadot's relay chain, for instance, serves as the backbone that allows different parachains (Layer 1) to securely and efficiently exchange information without having to worry about individual security or validation mechanisms.
Standalone L1 blockchains like Ethereum handle both the functions of the network itself and the infrastructure that allows DApps to run on them, while L1 blockchains like Astar, built on Layer 0 frameworks like Polkadot, benefit from the underlying shared security and interoperability features provided by the Layer 0 protocol.
One important Layer 1 scalability approach is sharding, a method that involves dividing the blockchain network into smaller, more manageable segments called “shards.” Each shard functions as its own mini-blockchain, capable of processing its own transactions, smart contracts, and data independently. By allowing multiple shards to process transactions in parallel, sharding significantly increases the overall throughput of the blockchain. Data is distributed across these shards, reducing the storage and processing burden on individual nodes. To maintain the integrity and consistency of the entire blockchain, shards must communicate with each other, ensuring that the global state remains accurate. The security of the network is upheld by a central chain or coordinator, such as the beacon chain in systems like Ethereum 2.0.
-
Layer 2 (L2): Layer 2 solutions are technologies built on top of existing Layer 1 blockchains and have been developed to improve scalability and efficiency without changing the main blockchain itself. They achieve this by processing transactions outside the main chain (off-chain), reducing the load on the main blockchain and enabling faster transactions with lower fees. Although they are built on top of the blockchain, they mainly use it for final settlement and security verification. Layer 2 solutions encompass various approaches, including Rollups, Sidechains, State Channels, and Nested Blockchains. Well-known projects include Raiden Network, zkSync, StarkWare, Polygon, and Skale Network.
-
Layer 3 (L3): Layer 3 refers to the application layer, which is based on Layer 2 technologies (or directly on Layer 1 if no Layer 2 solutions are used). This layer includes end-user applications, known as DApps (decentralized applications), which interact directly with users. Layer 3 developments focus on user experience and providing specific functions or services within the blockchain ecosystem. They are not part of the blockchain infrastructure itself but use the underlying layers to ensure that their applications function effectively. Examples of Layer 3 solutions include Uniswap, Compound, PancakeSwap, and OpenSea. They are integral to the blockchain ecosystem, driving user adoption and providing real-world utility by making blockchain technology accessible and functional for everyday use.
Everything is a Transaction
In blockchain technology, every interaction with the blockchain is fundamentally processed as a transaction. Whether deploying a new smart contract, transferring assets, interacting with an existing decentralized application (dApp), or participating in governance activities, each action is recorded and validated as a transaction on the blockchain. This transactional model is central to blockchain architecture, ensuring that every change to the state of the network is documented in a transparent and immutable manner.
For example, when a new smart contract is deployed, the deployment is executed as a transaction, containing the contract's code and initial parameters. This transaction is broadcast to the network, validated, and permanently recorded in the blockchain ledger. Similarly, when interacting with a smart contract—such as executing a function to exchange tokens—this interaction triggers a transaction that follows the same process of validation and recording.
The treatment of all interactions as transactions is essential due to the decentralized nature of blockchain networks. Each transaction must be validated through the network's consensus mechanism, ensuring its legitimacy and maintaining the integrity of the blockchain. This process prevents issues like double-spending and ensures that all nodes in the network maintain a consistent and accurate state.
Overall, the principle that "everything is a transaction" highlights the methodical way in which blockchain systems handle data and state changes, reinforcing the security and consistency of the network.
Token vs. Coin
For a Web2 developer, it is important to understand that "token" in the blockchain world has a much larger and more diverse meaning that goes beyond just authentication. However, in the context of Web3 and blockchain, the term refers to digital assets or units of value that are stored and managed on a blockchain.
Two concepts that are also often misinterpreted are that of a coin and a token. A token and a coin are both types of digital assets based on blockchain technology, but they are different in their basic structure and purpose.
A coin is a digital asset that lives in its own independent blockchain. It is the native currency of the blockchain and is integrated into the basic operation and security of the network. Tokens, on the other hand, are created and operated on existing blockchains. They use the infrastructure and security of the underlying blockchain, but are not a native currency of that blockchain.
Coins are primarily used as a medium of exchange, store of value and unit of account within their own blockchain system. They are used to process transactions and as compensation for the participants who secure and maintain the network. Tokens can represent a wide range of values and rights, such as access permissions, ownership shares, voting rights or they can be used in specific applications and ecosystems. They can be designed for specific functions within DApps, as part of a larger ecosystem, or as representatives of real-world assets.
A token can also serve as a coin within a particular ecosystem or project if it is frequently used to buy goods, services or participate in activities within that system. If a token functions beyond pure access as a generally accepted medium of exchange, store of value and unit of account in an ecosystem, it can take on characteristics of a currency.
In essence, coins are the primary currency of a blockchain and act as a general payment method. Tokens are usually designed for specific applications, rights or values that are used within an ecosystem. The distinction between tokens and coins is crucial in the blockchain space as it helps to understand the nature of the digital asset and its role within the blockchain ecosystem.