Demystifying Blockchain Technology: A Comprehensive Guide

Demystifying Blockchain Technology: A Comprehensive Guide

Introduction

If you have been active on the internet, you might have heard the term "blockchain" being thrown around a lot. But what exactly is a blockchain?

A blockchain is a distributed ledger with growing lists of records (blocks) that are securely linked together via cryptographic hashes. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a Merkle tree, where data nodes are represented by leaves).

- Blockchain - Wikipedia

Woah, that was a lot of words. Don't worry about it, we will go through them one by one.

Brief overview of blockchain technology.

Let's go over the definition again and try to break down individual pieces of it.

Blockchain is a decentralized, distributed ledger technology that securely records transactions across a network of computers.

Each block in the blockchain contains a list of transactions, and once a block is added to the chain, it is linked to the previous block, creating a chain of blocks.

This chain of blocks forms a tamper-resistant and transparent record of transactions.

  1. Decentralization: There is no central authority controlling the blockchain network. Instead, it is maintained by a network of nodes (computers) that validate and record transactions.

  2. Transparency: All transactions are recorded on the blockchain and are visible to all participants in the network. This transparency helps prevent fraud and ensures trust among users.

  3. Immutability: Once a transaction is recorded on the blockchain, it cannot be altered or delete. This feature makes the blockchain tamper-proof and secure.

  4. Security: Blockchain uses cryptographic techniques to secure transactions, making it extremely difficult for unauthorized parties to tamper with the data.

These are the key features which make blockchain a capable technology with applications ranging from (but not limited to) cryptocurrencies, finance, supply chain management, healthcare and many more to create transparent, secure and efficient systems for recording and verifying transactions. It is also,

  1. Driving Innovation: It has sparked innovation in various industries, leading to the development of new business models and applications. This includes decentralized finance (DeFi), non-fungible tokens (NFTs), and more.

  2. Increasing Financial Inclusion: It has the potential to improve financial inclusion by providing access to financial services to underserved populations. For example, blockchain-based systems can enable cross-border payments at lower costs and faster speeds.

A Brief History

Blockchain evolution timeline -

  • 1991: Stuart Haber and W. Scott Stornetta propose a cryptographically secured chain of blocks for secure document timestamping.

  • 1992: Merkle Trees are incorporated into the design, allowing efficient storage of multiple documents within a single block.

  • 1994: Concept of smart contracts was originally conceived by Nick Szabo. "Smart contracts are a set of instructions executed in a decentralized way without the need for a centralized or third-party intermediary."

  • 2000: Stefan Konst publishes theories on cryptographic chains and their implementation.

  • 2004: Hal Finney introduces "Reusable Proof of Work," a significant concept for digital cash and preventing double-spending.

  • 2008: Pseudonymous 'Satoshi Nakamoto' publishes a white paper outlining "Bitcoin: A Peer-to-Peer Electronic Cash System," introducing the first distributed blockchain for Bitcoin transactions.

  • 2009: The Bitcoin network goes live, marking the birth of the first cryptocurrency and practical implementation of blockchain technology.

  • 2014: Blockchain 2.0 emerges as the technology's potential extends beyond just cryptocurrency. Financial institutions and other industries begin exploring blockchain applications.

  • 2015: Ethereum launches its Frontier Network, enabling developers to build and deploy smart contracts and decentralized applications (dApps) on a live network. The Linux Foundation also initiates the Hyperledger project for enterprise blockchain development.

  • 2016: "Blockchain" becomes a universally recognized term. A bug in Ethereum's DAO code leads to a hard fork and highlights security challenges.

  • 2017: Japan recognizes Bitcoin as legal tender. Block.one introduces the EOS blockchain platform designed for commercial dApps.

  • 2018: The value of Bitcoin fluctuates significantly. Major online platforms ban cryptocurrency advertising.

  • 2019: Ethereum network transactions surpass 1 million daily. Amazon launches its Managed Blockchain service.

  • 2020: Stablecoins gain traction due to their price stability compared to traditional cryptocurrencies. Ethereum launches Beacon Chain, paving the way for Ethereum 2.0.

  • 2022: Ethereum successfully transitions from Proof-of-Work (PoW) to Proof-of-Stake (PoS) consensus mechanism, significantly reducing its energy consumption.

How Do Blockchains Work?

In order to understand the working of blockchain we have to understand a couple of terms.

Here we're going to break down blockchains, the process and the technology itself using a widely praised and accessible demo available here - Blockchain Demo (andersbrownworth.com).

Hash

Demo link uses SHA256 - Blockchain Demo - Hash.

While concept would be the same, implementation of hash function might be different. Example, Bitcoin uses SHA256 while Ethereum uses Keccak256.

Imagine hash like a digital fingerprint. Hash is a unique identifier created by a mathematical function called a hash function. It works as,

  • Takes in an Input: Any data, like a block of information in a blockchain.

  • Hash Function is applied: A complex mathematical algorithm that crunches the input data.

  • Output: We get fixed-size string of characters called a hash.

Hash is used due to some key features which are,

  • Unique: The same input data will always generate the same hash, but different data will almost never produce the same hash.

  • Fixed size: Regardless of the size of the input data, the hash will always be the same length.

  • One-way: You can easily generate a hash from data, but it's nearly impossible to recreate the original data from just the hash.

Block

A block in blockchain is like a container that hold important information about transactions. 'Block' is the fundamental building block of blockchain (no pun intended).

Here's a breakdown of what a block typically contains:

  • Transaction Data: This could be cryptocurrency transfers, data exchanges in a supply chain, or even code for smart contracts (depending on the blockchain).

  • Timestamp: This indicates the exact time the block was created, further solidifying the chronological order of transactions.

  • Hash: A unique digital fingerprint of the block's contents created using a cryptographic hash function. Any change to the data within the block will completely alter the hash, making it easy to detect tampering.

Blockchain

If the block is not taken in isolation and is chained by adding the previous block's hash, a Blockchain is created. It typically contains,

  • Transaction Data

  • Timestamp

  • Hash

  • Previous Block Hash: Each block also contains the hash of the block before it in the chain. This creates a link between blocks, ensuring they follow a specific order and cannot be inserted or removed without affecting the entire chain.

In this manner a chain-of-block is created. These blocks are chained together chronologically to create a secure and tamper-proof record.

Hashes play a vital role in securing blockchains by,

  • Verifying Data Integrity: Hashes ensure the data within a block hasn't been tampered with. If someone changes even a single bit in the data, the hash will completely change, alerting miners and users to a potential issue.

  • Linking Blocks: Each block in a blockchain contains the hash of the previous block, creating a chain-like structure. This makes it nearly impossible to alter past data without altering all subsequent blocks and their hashes.

Think of it like this: Imagine a public ledger where each page (block) contains a record of recent events (transactions) with a unique code (hash) and a reference to the previous page (previous block hash). This makes it very difficult to forge or alter entries because any change would disrupt the entire chain.

Nonce

A block takes in a data input, but instead of a singular data field, a block is divided into 'block', 'nonce', and 'data.'

All three are then run through the hash algorithm, producing the hash for that block.

In essence, mining involves the computational trial and error process of finding an acceptable value to produce a hash which typically follows a certain pattern, for example such as starting with four zeros.

The value found, which satisfies this criterion, is known as the 'nonce'.

The problem or criteria, a miner has to solve will vary from blockchain to blockchain, but the concept is the same.

Decentralized Blockchain

If a single entity were to control the blockchain, they could conveniently change any data they want, and then re-mine, or re-validate subsequent blocks. This defeats the purpose of immutability if it cannot be changed but can be created again!

To solve this each node (computer) in the network contains a copy of the ledger. This system with multiple entities or "peers" with equal weight and power maintain the integrity of the chain.

In the event of disparity between the blockchains run by different peers (due to tampering or otherwise), the majority hash wins, as the majority of the network agrees on it.

Signing transactions

Blockchain transactions rely on digital signatures for verification. Your private key signs the transaction, while the public key allows others to confirm its authenticity.

Understanding private and public keys is crucial for blockchain transactions. When you send one, your private key signs it, and the public key enables verification by others.

Both Ethereum and Bitcoin utilize Elliptic Curve Digital Signature Algorithm (ECDSA) for signing transactions. This cryptographic method ensures your private key remains undecipherable from the message signature.

Gas

Another term which you might see a lot is 'gas' which refers to the fee required to process a transaction or execute a smart contract on the network.

It's like a toll you pay to use the blockchain highway.

  • Units: Gas is measured in smaller units specific to each blockchain. For example, on Ethereum, gas is priced in gwei (1 gwei = 0.000000001 ETH).

  • Purpose:

    • Rewarding Miners/Validators: Gas fees compensate miners or validators (depending on the consensus mechanism) for processing transactions and securing the network.

    • Preventing Spam: Gas fees discourage spam by adding a cost barrier. Without fees, the network could be clogged with meaningless transactions.

  • Transaction Cost:

    • Gas Limit: The maximum amount of gas a user is willing to spend on a transaction, preventing accidental overspending.

    • Gas Price: The user-defined price per unit of gas. A higher gas price incentivizes miners during network congestion.

Think of gas fees as payment for computational resources needed to process transactions—a budget (gas limit) with an hourly rate (gas price).

Consensus

The mechanism used to reach an agreement on the state or a single value on the blockchain especially in a decentralized system.

Very roughly, a consensus protocol in a blockchain or decentralized system can be broken down into two pieces a chain selection algorithm and a sybil resistance mechanism.

  • Consensus algorithms are crucial for blockchain networks to validate transactions and maintain a shared ledger. Here's a quick overview of some popular ones:

    1. Proof of Work (PoW): Miners compete to solve complex puzzles, the winner gets to add the next block. (e.g. Bitcoin)

    2. Proof of Stake (PoS): Validators lock up tokens as a stake, selection for block creation is based on stake size. (e.g. Ethereum 2.0)

    3. Delegated Proof of Stake (DPoS): Users delegate voting rights to others who validate transactions.

    4. Proof of Burn (PoB): Validators burn tokens to participate, the more burned, the higher the chance to mine a block.

    5. Proof of Capacity (PoC): Storage space determines block creation probability, more space, better chance to win.

    6. Proof of Elapsed Time (PoET): Nodes wait for a random time, the one waiting the least creates the block.

Choosing the right algorithm depends on the specific needs of the blockchain network.

Blockchain attacks

There are two major types of attacks that exist in the blockchain space.

  • Sybil Attack - When a user creates a number of pseudo-anonymous accounts to try to influence a network.

  • 51% attack - Occurs when a single entity possesses both the longest chain and majority network control. This would allow the entity to fork the chain and bring the network onto the entities record of events, effectively allowing them to validate anything.

Bitcoin and Ethereum

Most popular and the biggest blockchains today are Bitcoin and Ethereum; let's look at some of the differences between them.

  • Currency vs. Platform: Bitcoin is a decentralized digital currency for peer-to-peer payments. Ethereum is a platform with its own currency (Ether) that allows for building applications and smart contracts.

  • Focus: Bitcoin prioritizes security and store-of-value. Ethereum emphasizes programmability and versatility.

  • Smart Contracts: Ethereum offers a more robust and flexible environment for smart contract development compared to Bitcoin. Technically Bitcoin does have smart contracts but they're intentionally turing incomplete.

  • Transactions: Bitcoin transactions mainly involve transferring value. Ethereum transactions along with transferring value can execute smart contracts and interact with decentralized applications (dApps).

All in all, Bitcoin is termed as "digital gold" for storing value, there is a fixed amount of Bitcoin, similar to the scarcity of gold. While Ethereum is a platform for building blockchain applications.

Smart Contracts: Code Meets Trust

Idea of Smart contract is simple, a set of actions take place based on a set of rules which are predefined and immutable, once enforced.
Like a vending machine that dispenses a soda only after you insert the exact number of coins.

Smart contract – a self-executing program stored on a blockchain that facilitates agreements between parties without a central authority.

Here are some real-world applications of smart contracts:

  • Supply chain management: Track the movement of goods and ensure timely payments.

  • Elimination of Counterparty Risk: Smart contracts eliminate the need for trust in transactions. Once a smart contract is deployed, its terms cannot be changed. This ensures that the agreement is enforced as originally intended.

  • Decentralized finance (DeFi): Borrow, lend, and trade cryptocurrencies without relying on banks.

  • Decentralized Autonomous Organizations (DAOs): DAOs are governed entirely by smart contracts and operate in a decentralized manner. This structure offers benefits such as transparent governance, efficient engagement, and clear rules.

  • Non-Fungible Tokens (NFTs): NFTs, or Non-Fungible Tokens, can be thought of as digital art or unique assets.

  • Escrow services: Securely hold funds until certain conditions are met.

The Oracle Problem: Feeding the Blockchain with Real-World Data

Blockchains are deterministic systems, which means everything happens within their ecosystem. Smart contracts are great for automating tasks, but they too operate within a closed system.

How can they access and interact with real-world data? This is where the oracle problem comes in.

Oracles act as bridges, feeding

external information into the blockchain to enable smart contracts to function effectively.

Here are some approaches to tackling the oracle problem:

  • Centralized oracles: Relied upon by some platforms, but raise concerns about trust and single points of failure.

  • Decentralized oracles: Utilize a network of nodes to gather and verify data, promoting transparency and security.

    Example -Chainlink is a popular decentralized Oracle network that enables smart contracts to access external data and computation. Chainlink is also blockchain agnostic - so it's going to work with any chain out there.

Layer 1 vs. Layer 2: Scaling the Blockchain Beast

As blockchain adoption grows, the number of transactions skyrockets. This can lead to network congestion and high fees. Here's where layer 1 and layer 2 solutions come into play:

  • Layer 1 (on-chain):

    • Transactions are directly processed and validated by the main blockchain, ensuring maximum security but limited scalability
  • This refers to base layer blockchain implementations like Bitcoin or Ethereum.

  • Sharding is a popular layer-1 scaling solution used to increase transaction throughput. The technique is a form of database partitioning that can be applied to blockchain distributed ledgers.

  • Layer 2 (off-chain): Transactions are processed off the main chain for faster speeds and lower costs, with security ultimately relying on the underlying layer 1.

Layer 1 blockchains offer a variety of solutions to the scalability trilemma (decentralization, security, scalability). Here are some examples,

  • Sui (SUI):

    • Aims to be the first internet-scale programmable blockchain platform, offering unmatched scalability and instant settlement.

    • Focuses on a safe and accessible smart contract language for mainstream developers.

    • Enables defining rich and composable on-chain assets for a better web3 user experience.

  • Elrond (EGLD): Uses sharding for high transaction speeds (100,000 TPS) and a Secure Proof of Stake (SPoS) consensus mechanism.

  • Harmony (ONE): Employs Effective Proof of Stake (EPoS) with sharding and focuses on cross-chain finance with bridges to Ethereum and Bitcoin.

  • Celo (CELO): Forked from Ethereum, it uses Proof of Stake (PoS) and allows phone numbers or emails as public keys for wider adoption.

  • THORChain (RUNE): A permissionless DEX built on Cosmos that enables decentralized cross-chain liquidity without asset pegging.

  • Kava (KAVA): Combines Cosmos's speed with Ethereum's developer tools. Uses Tendermint PoS and features co-chains for both EVM and Cosmos environments.

  • IoTeX (IOTX): Focuses on the Internet of Things (IoT), allowing users control over device data. Offers hardware products like Ucam (security camera) and Pebble Tracker (GPS tracker).

Additional Popular Platforms:

  • Ethereum (ETH): The first smart contract platform, known for its flexibility and widespread use.

  • Solana (SOL): Offers fast transaction speeds and low costs.

  • Cardano (ADA): Focuses on security and sustainability.

  • BNB Chain (BNB): Compatible with Ethereum and boasts high throughput.

Directed Acyclic Graph (DAG) Platforms:

  • IOTA (MIOTA): Designed for the IoT, offering feeless transactions.

  • Fantom (FTM): Known for its high speed and scalability.

  • Hedera Hashgraph (HBAR): Offers high throughput and fair transaction ordering.

As blockchains grow, they face scaling issues. Layer 2, or L2, solutions have been developed to address this. L2 solutions involve other blockchains hooking into the main blockchain, essentially allowing it to scale. There are two primary types of L2 solutions:

  • Lightning Network: Used primarily with Bitcoin, enables fast and cheap micropayments.

  • Rollups: Bundle transactions off-chain and periodically submit them to the main chain for validation, offering a good balance of scalability and security.

    • Optimistic Rollups: e.g. Optimism, Arbitrum

    • Zero-Knowledge Rollups: e.g. ZK Sync, Polygon ZK EVM

Web3: A New Dawn for the Internet?

Web3 reimagines the internet as a user-controlled space. Built on blockchain technology, it removes central authorities, giving users ownership of their data and online interactions.

This decentralized approach promises transparency, censorship resistance, and the ability to own digital assets – ushering in a new era of online empowerment.

Evolution of internet,

  • Web1: The permissionless open sources web with static content

  • Web2: The permissioned web, with dynamic content where companies run your agreements on their servers.

  • Web3: The permissionless web with dynamic content.

Here's how Web3 could change the way we use the internet:

  • Decentralized applications (dApps): Web applications that run on a peer-to-peer network, reducing reliance on centralized platforms.

  • Ownership of digital assets: Users can truly own and control their digital creations, such as data and artwork, where they own a portion of the protocol they interact with, rather than just being the product.

  • A more democratic internet: Power could shift away from big tech companies towards individual users.

  • Decentralized censorship resistant networks run your agreement and code.

The Future is Unwritten

Blockchain technology has emerged as a revolutionary force with the potential to transform various industries. While the technology is promising, it is still developing and exploring its use cases. There is massive potential and opportunities available, similar to what we witnessed in the early days of the internet.

The landscape of smart contracts, scaling solutions, and Web3 is constantly evolving. While challenges remain, the potential for a more secure, transparent, and user-centric internet is undeniable.

I am excited to dive deeper. Are you?

Stay tuned for further exploration of these exciting concepts!

via GIPHY

Resources

Introduction and history

How blockchains work

Smart contracts

Web3

Did you find this article valuable?

Support Eshan's Blog by becoming a sponsor. Any amount is appreciated!