DEV Community

ASHDEEP SINGH
ASHDEEP SINGH

Posted on

An Intro to blockchain

Blockchain

Blockchain is a distributed immutable ledger that is completely transparent. Let's break that down. Distributed means it is not available on a single machine, hence not centrally controlled. Immutable refers to the fact that it can't be changed (we'll see that later). Ledger means it contains a record of all the transactions that have occurred.

Uses of blockchain technology are quite popular, like in cryptocurrencies, cross-border payments, etc. Let me show you something interesting.

Types of blockchain: public & private

Let me cut and paste ChatGPT's answer (because it's from ChatGPT that I learned it).

Public and private blockchains are two primary types of blockchain networks, each with distinct characteristics, advantages, and use cases. Here’s a detailed comparison:

Public Blockchain

Definition: A public blockchain is a decentralized network accessible to anyone who wants to participate. It is open-source and allows anyone to join the network, validate transactions, and maintain the shared ledger.

Characteristics:

Decentralization: No single entity controls the network.

Transparency: All transactions are visible to everyone on the network.

Security: High level of security due to consensus mechanisms like Proof of Work (PoW) or Proof of Stake (PoS).

Anonymity: Participants can remain pseudonymous.

Immutability: Once data is recorded, it cannot be altered.
Enter fullscreen mode Exit fullscreen mode

Examples:

Bitcoin: The first and most well-known public blockchain.

Ethereum: A public blockchain that supports smart contracts and decentralized applications (dApps).
Enter fullscreen mode Exit fullscreen mode

Advantages:

Trustless: No need for participants to trust each other or a central authority.

Open Access: Anyone can participate and contribute to the network.

Transparency: Enhances trust through visibility of all transactions.
Enter fullscreen mode Exit fullscreen mode

Disadvantages:

Scalability: Typically slower transaction processing times and higher costs due to the need for widespread consensus.

Energy Consumption: High energy usage, especially with PoW consensus.
Enter fullscreen mode Exit fullscreen mode

Private Blockchain

Definition: A private blockchain is a restricted network where access is limited to specific participants. It is typically used by organizations for internal purposes and is controlled by a single entity or consortium.

Characteristics:

Controlled Access: Only authorized participants can join the network and validate transactions.

Privacy: Transactions are visible only to authorized participants.

Centralization: Managed by one or a few organizations.

Efficiency: Faster transaction processing due to fewer nodes and simpler consensus mechanisms.

Governance: The controlling entity or consortium can alter the rules or data.
Enter fullscreen mode Exit fullscreen mode

Examples:

Hyperledger Fabric: A modular framework for building private blockchain applications.

Corda: Designed for business use, focusing on privacy and scalability.
Enter fullscreen mode Exit fullscreen mode

Advantages:

Scalability: Higher transaction speeds and lower costs.

Privacy: Greater control over who can see and validate transactions.

Customizability: Can be tailored to specific organizational needs.

Energy Efficiency: Lower energy consumption due to simpler consensus mechanisms.
Enter fullscreen mode Exit fullscreen mode

**
Disadvantages:**

Trust: Requires trust in the central authority or consortium.

Limited Transparency: Not all transactions are visible to all participants, which may reduce trust.

Centralization: Potential single points of failure and control.
Enter fullscreen mode Exit fullscreen mode

Architecture

Each block of blockchain has the following components:

  • Block number
  • Data
  • Prev Hash

Prev Hash is the hash of the previous block. For the 1st block (also called the genesis block), the hash is 0. Using hash makes it immutable as if you change one block's data, its hash changes, thus making a new block, thus depicting data has been changed. The common hashing algorithm used is SHA256.

Using this blockchain technology, we can construct various things, one such is cryptocurrency like Bitcoin, Ethereum, Dogecoin, etc.

Now let us move to the world of cryptocurrency. Till now we have understood most of the cryptocurrency-backed tech. One thing to know is not each cryptocurrency is the same. For example, Bitcoin is not Turing complete while Ethereum is. Referring to Cointelegraph, "In computer science and blockchain technology, the term 'Turing completeness' describes a system's ability to carry out any computation that a Turing machine is capable of." In Bitcoin's world, the computation we cannot perform is a for loop. Seems intriguing? Well, the founder of Bitcoin thought that if we run a for loop, we can run into an infinite loop. However, the founder of Ethereum came up with a very genius idea stating that if each transaction costs some unit (called GAS), then we can terminate the operation if it costs more GAS than estimated. Thus each operation will be completed only if the GAS used for it is less than the GAS estimated.

Good To Know

GAS is not the same as Ether. GAS is a unit, its cost is in gwei which is in Ether.

The rate of GAS depends upon the transaction. (Refer to the opcode manual to know how much it costs for an operation).

And that's all folks. Stay tuned for more.

Signing off

Peace

Top comments (0)