Blockchain Architecture Design Notes
Blockchain Architecture Design Notes
Module 1
Introduction to Blockchain
What is Blockchain?
• Blockchain is a type of digital database (or ledger) where information is
stored securely in "blocks" that are linked together like a chain.
• Once a piece of information is added to the blockchain, it cannot be
changed, ensuring transparency and security.
• Think of it as a digital notebook where each page (block) is locked and
connected to the previous one.
Blockchain Architecture
1. Structure of a Block:
Each block in the blockchain consists of two main parts:
o Block Header:
▪ Hash: A digital fingerprint unique to the block.
▪ Previous Block Hash: Links the current block to the previous
one.
▪ Timestamp: Records the date and time the block was created.
▪ Nonce: A random number used for mining.
o Block Body:
▪ Contains a list of verified transactions.
2. How Blockchain Works:
o A transaction is created (e.g., Alice sends money to Bob).
o The transaction is broadcasted to the network for verification.
o Verified transactions are grouped into a block.
o The block is added to the blockchain using a consensus mechanism.
Types of Blockchain
Public Blockchain
• Open to everyone. Anyone can join and participate.
• Example: Bitcoin, Ethereum.
Private Blockchain
• Access is restricted to certain participants.
• Used within organizations for internal purposes.
• Example: Supply chain tracking in a company.
Module 2
Bitcoin Basics
What is Bitcoin?
• Bitcoin is the first and most popular cryptocurrency, introduced by Satoshi
Nakamoto in 2008.
• It uses blockchain technology to enable decentralized, secure, and
transparent digital transactions.
How Bitcoin Works:
1. Blockchain as the Foundation: Bitcoin operates on a public blockchain
where all transactions are recorded.
2. Peer-to-Peer Network: Users directly send and receive Bitcoin without
intermediaries like banks.
3. Digital Wallets: Users store Bitcoin in digital wallets, secured by private and
public keys.
4. Mining: Specialized computers (miners) solve complex mathematical
problems to validate transactions and add them to the blockchain.
Key Features:
• Decentralized: No central authority like a bank or government.
• Finite Supply: Only 21 million Bitcoins will ever be mined.
• Secure: Cryptographic techniques ensure data integrity and transaction
authenticity.
Distributed Consensus
What is Distributed Consensus?
• A process where all nodes in a blockchain network agree on the validity of
transactions and the state of the blockchain.
• This prevents fraudulent or duplicate transactions.
Why is it Important?
• Ensures that all copies of the blockchain across the network remain
consistent.
• Eliminates the need for a central authority to validate transactions.
Consensus in Bitcoin
Basics:
• Bitcoin uses a consensus mechanism called Proof of Work (PoW).
• PoW ensures that miners compete to solve a complex mathematical
problem, and the first to solve it adds the next block to the blockchain.
Proof of Work (PoW):
1. Goal: Miners solve a cryptographic puzzle to validate transactions.
2. How it Works:
o Miners compete to find a number (nonce) that, when combined with
the block data, produces a hash that meets the network’s difficulty
target.
3. Benefits:
o Secure and decentralized.
4. Drawbacks:
o Energy-intensive.
o Slow transaction speeds.
Beyond PoW:
• Proof of Stake (PoS): Validators are chosen based on the amount of
cryptocurrency they hold.
• Delegated Proof of Stake (DPoS): Users vote for delegates to validate
transactions.
The Miners:
• Role: Validate transactions, solve PoW puzzles, and secure the network.
• Rewards: Miners earn Bitcoin as a reward for adding a new block to the
chain.
Permissioned Blockchain
Basics:
• A permissioned blockchain restricts access to specific participants.
• Used for private or enterprise applications where only authorized members
can validate transactions.
Consensus in Permissioned Blockchains:
1. Efficiency: Faster and more scalable than public blockchains.
2. Examples:
o Hyperledger Fabric: A permissioned blockchain for enterprise use.
o Corda: Focused on financial institutions.
RAFT Consensus:
• A lightweight consensus mechanism used in permissioned blockchains.
• Works by electing a "leader" node to coordinate decisions among the
nodes.
Byzantine Generals Problem:
• A classic problem in distributed computing where participants must agree
on a strategy, even if some are unreliable or malicious.
• Blockchain solves this problem through mechanisms like PoW or Practical
Byzantine Fault Tolerance (PBFT).
Practical Byzantine Fault Tolerance (PBFT):
• Designed to handle up to 1/3 of malicious nodes.
• Nodes exchange messages to reach consensus on the state of the
blockchain.
Module 3
Introduction to Ethereum
What is Ethereum?
• Ethereum is a decentralized platform that allows developers to build and
deploy applications (called DApps) on its blockchain.
• Unlike Bitcoin, which focuses solely on digital currency, Ethereum is more
flexible, supporting Smart Contracts—self-executing agreements with
predefined rules.
• It was created by Vitalik Buterin in 2015 to expand blockchain technology
beyond financial transactions.
Key Features of Ethereum:
1. Smart Contracts: Self-executing agreements coded into the blockchain.
2. Decentralized Applications (DApps): Applications that run on a blockchain
instead of a central server.
3. Ether (ETH): The native cryptocurrency of Ethereum, used for transactions
and computational costs (gas fees).
Setting Up Metamask
What is Metamask?
• A browser extension and mobile app that acts as a crypto wallet for
Ethereum.
• It allows users to store Ether (ETH), interact with Ethereum-based DApps,
and manage private keys.
Steps to Set Up Metamask:
1. Download:
o Go to the official Metamask website or app store and download the
extension/app.
2. Create a Wallet:
o Follow the prompts to create a new wallet.
o Set a strong password.
3. Backup the Seed Phrase:
o Save the 12-word seed phrase securely. It’s your only way to recover
the wallet if lost.
4. Access Wallet:
o Once setup is complete, you can send, receive, and store Ether and
tokens.
Ethereum Accounts
Types of Accounts:
1. Externally Owned Accounts (EOA):
o Controlled by private keys.
o Used by individuals to hold ETH and initiate transactions.
o Example: A personal wallet on Metamask.
2. Contract Accounts:
o Linked to smart contracts, not controlled by private keys.
o Executes code when certain conditions are met.
Receiving Ether
Steps to Receive Ether (ETH):
1. Get Your Wallet Address:
o Copy your Ethereum address from your wallet (e.g., Metamask).
2. Share Your Address:
o Share the address with the sender.
3. Transaction Confirmation:
o Once the sender transfers ETH, the transaction will be confirmed on
the Ethereum blockchain.
What’s a Transaction?
Definition:
• A transaction is an operation that interacts with the Ethereum blockchain.
• Example: Sending ETH, deploying a smart contract, or calling a smart
contract function.
Transaction Components:
1. Sender Address: The account initiating the transaction.
2. Recipient Address: The account receiving the transaction.
3. Gas Fees: The cost of processing the transaction.
4. Data: Optional information or function calls (e.g., smart contract execution).
Gas Fees Explained:
• Transactions on Ethereum require gas fees, paid in ETH, to compensate
miners/validators for computational work.
• Gas Limit: The maximum gas a user is willing to spend.
• Gas Price: The cost per unit of gas, determined by the network demand.
Smart Contracts
Benefits:
• Trustless: Operate without requiring a trusted third party.
• Transparent: Rules and transactions are visible to all participants.
• Immutable: Code cannot be altered after deployment.
Limitations:
1. Bugs in Code: A poorly written smart contract can lead to vulnerabilities.
2. High Gas Costs: Complex contracts require more computational power and
higher fees.
Module 4
Introduction to Hyperledger
What is Hyperledger?
• Hyperledger is an open-source collaborative project initiated by The Linux
Foundation in 2015.
• It is not a single blockchain but a collection of blockchain frameworks,
tools, and libraries aimed at building enterprise-grade blockchain systems.
• Unlike public blockchains like Bitcoin and Ethereum, Hyperledger is
primarily focused on permissioned blockchains for business applications.
Purpose of Hyperledger:
• To help organizations create secure, private, and scalable blockchains
tailored to their specific needs.
• It provides a modular design that allows businesses to customize
components like consensus mechanisms, identity management, and privacy
settings.
Key Projects Under Hyperledger:
1. Hyperledger Fabric: A framework for building permissioned blockchains.
2. Hyperledger Composer: A toolset for developing blockchain applications.
3. Hyperledger Sawtooth: Focused on flexibility and scalability.
4. Hyperledger Indy: Designed for decentralized identity management.
Conclusion
Hyperledger provides a robust platform for enterprises to build secure, private,
and efficient blockchain systems. Fabric’s modular architecture ensures scalability
and privacy, while Composer simplifies application development. Together, they
empower organizations to overcome traditional challenges of Distributed Ledger
Technology and implement blockchain solutions tailored to their unique needs.
Module 5
Solidity Programming
What is Solidity?
• Solidity is a high-level programming language designed specifically for
writing smart contracts on the Ethereum blockchain.
• Smart contracts are self-executing contracts with the terms of the
agreement directly written into code.
• Solidity is statistically typed, meaning the type of data must be defined at
the time of creation.
• The language is influenced by JavaScript, Python, and C++, making it
familiar to many developers.
Basics of Solidity
1. Smart Contracts: Solidity allows the creation of smart contracts that can be
deployed on the Ethereum blockchain. These contracts are immutable once
deployed, meaning they cannot be changed.
2. Ethereum Virtual Machine (EVM): Solidity runs on the Ethereum Virtual
Machine, which is responsible for executing smart contracts. The EVM
ensures that all nodes in the network can execute the contract's logic
identically.
3. Gas: Gas is a fee required to execute operations on the Ethereum network.
Solidity developers need to optimize their code to reduce gas usage.