Blockchain Fundamentals

Blockchain BasicsFree Lesson

Advertisement

Blockchain Fundamentals

Core concepts, distributed ledger technology, consensus mechanisms, and blockchain architecture.

Overview

Blockchain is a distributed, immutable ledger for recording transactions.

Core Concepts

Block Structure

{
  "index": 1,
  "timestamp": 1705123456789,
  "data": {
    "transactions": [...]
  },
  "previousHash": "0000000000000000000...",
  "hash": "0000abc123...",
  "nonce": 12345
}

Key Properties

PropertyDescription
DecentralizationNo single point of control
ImmutabilityCannot alter past records
TransparencyOpen verification
ConsensusAgreement on state

Consensus Mechanisms

Proof of Work (PoW)

def proof_of_work(block, difficulty=4):
    target = "0" * difficulty
    nonce = 0
    while True:
        block.nonce = nonce
        block_hash = calculate_hash(block)
        if block_hash.startswith(target):
            return nonce, block_hash
        nonce += 1

Proof of Stake (PoS)

def select_validator(stakeholders):
    total_stake = sum(s.stake for s in stakeholders)
    random_point = random.uniform(0, total_stake)
    
    current = 0
    for validator in stakeholders:
        current += validator.stake
        if current >= random_point:
            return validator

Network Types

TypeAccessExample
PublicOpen to allBitcoin, Ethereum
PrivateRestrictedHyperledger
ConsortiumGroup-controlledR3 Corda
HybridMixedEnterprise solutions

Blockchain Architecture

Architecture Diagram
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│           Application Layer         │
│  (Smart Contracts, DApps)           │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Network Layer             │
│  (P2P, gossip protocol)             │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Consensus Layer           │
│  (PoW, PoS, BFT)                    │
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
│           Data Layer                │
│  (Blocks, Merkle trees)             │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Practice

Implement a simple blockchain with proof of work.

Advertisement

Need Expert Blockchain Help?

Get personalized Web3 training or smart contract consulting.

Advertisement