🔗 Blockchain Basics
Tags: blockchain, tutorial, beginners
Published: 2022-05-16 17:06:17

## History of Blockchain

The blockchain was first introduced in 2008 as a public ledger for keeping records of transactions for Bitcoin. This method of recording transactions was transparent. Every record was timestamped, immutable (meaning no one could change/remove a record after it had been added), and decentralized.

It was invented by a guy or probably a group of people, or even an AI who goes by the name _[Dorian Satoshi Nakamoto](https://en.wikipedia.org/wiki/Satoshi_Nakamoto)_.

Around the year 2014, the blockchain started to gain traction and attention. People began to invest in it after seeing that it had more applications than just cryptocurrency. It could be used in various fields such as insurance and finance, healthcare, voting, transportation, and others.

---

## What is a blockchain?


<img src="https://i.redd.it/4nou9vfuod271.jpg" alt="What is Blockchain" width="500" height="500"/>

The blockchain is a distributed database or record-keeping system for storing digital records in a structure that makes it difficult to hack the system. The blockchain does not store data in a centralized location, unlike a traditional database. Instead, each node/computer on the network has a complete copy of the blockchain. When data is saved on the system, it is distributed to thousands of network nodes.

---

## How does the blockchain work?

The blockchain stores sets of data in collections known as _blocks_. Blocks are like containers. Every container has a limit or a maximum amount of content it can hold. In terms of blocks, the total amount of data it can contain is known as _block size limit_

The capacity of each block is referred to as the block size, and it varies depending on the blockchain (ranging from a few kilobytes to roughly 1 megabyte).

The block size of Bitcoin is around 1MB, and that of Ethereum is roughly 80KB.

Although the block sizes appear small, they can carry up to 2000 transactions. Every block is stored linearly and chronologically, with each new block added to the end of the chain. When a block reaches its maximum block size, it’s closed and connected to another block using a hashing algorithm, a type of cryptographic validation. As a result, a continuous chain of blocks is formed, giving rise to the name **blockchain**. However, if a block exceeds the block size, the network rejects it and is not added to the chain.

---

## What makes the blockchain secure and immutable?

The immutability of the blockchain is due to the hashes of the blocks. A hash is similar to a fingerprint. Humans all have different fingerprints. In the case of blocks, hashes serve as unique identifiers/fingerprints. Each block is digitally signed with a unique hash generated by a hashing algorithm/a hash function. The current block, the previous block, and a timestamp are used to generate these hashes, and the slightest change of input will result in a whole new hash.

Hash values normally look like this: _3a42c50395390963741kdd8c99b3b8uydde362417585af87l901bdefe8349102_

Think of a hash function as a grinding machine. A grinding machine only works in one direction. It starts with a raw item and grinds it down into smaller pieces. A hash function functions similarly in that it takes raw data and converts it into an encrypted format that cannot be reverse-engineered. There is no way to recover the original values generated into the hash, just as ground meat cannot be converted back to its original form after passing through a grinding machine.

![How does the blockchain store information](https://miro.medium.com/max/589/0*GDlCR03BNjUt3wlz.png)

Assume a hacker wanted to change a blockchain record. First, the hacker must run his node and locate the block he wants to modify. If he is successful in changing this block/making this change, the newly generated hash will not match the original hash, rendering the block invalid in the chain.

Keep in mind that this modification is currently only available on his node. What's more, before a record is added to the main public chain, it must be verified by the other nodes. If the majority of nodes (at least 51 per cent) confirm the validity of the new change, it can be added to the chain; otherwise, it is considered invalid and rejected. As a result, for this to be possible, the hacker will need to perform this exact change on most nodes/computers, which will require a large number of resources and is practically impossible.

![understanding blockchain](https://www.memesmonkey.com/images/memesmonkey/4b/4b6ab3582271daad0b168404458969e6.jpeg)

---

## Characteristics of blockchain

-   **Decentralized**. This is one of the key features of the blockchain. Except for private blockchains, the blockchain does not have a central authority managing the network's activities; instead, the nodes maintain the network and validate transactions. You can store your important digital assets on the chain, and you have direct control over these assets via your private keys. **Private keys** are like cryptographically generated passwords used for signing transactions and proving ownership of a blockchain address.
    
-   **Transparent and open**. The blockchain stores all records and transactions publicly, making them accessible to anyone at any time. The blockchain is designed so that no one can cover up anything and use it for personal gain.
    
-   **Enhanced Security and immutability**. Every piece of data on the blockchain is hashed. That is, you cannot specify the actual content of the data. Furthermore, since the hashes cannot be reverse-engineered, it adds an extra layer of security. And because of the advanced cryptography and uniqueness of the block hashes, tampering with any block will require changing all the hashes of the other blocks on the majority of the nodes, which is a lot of work and a lot of resources.

---

## Nodes

![blockchain nodes](https://miro.medium.com/max/660/1*Vsd12by9jBlba2Jv-4zugw.png)

A blockchain node is a computer or device that runs blockchain client software, has a complete copy of the blockchain data, and can validate transactions, messages, and blocks on the blockchain.

#### Types of nodes

Blockchain nodes are classified into two main kinds; Lightweight nodes and Full nodes. There are a variety of types of nodes. They are:

-   Light Nodes
-   Masternodes
-   Pruned Full Nodes
-   Archival Full Nodes
-   Mining Nodes
-   Lightning Nodes

#### Full nodes vs Lightweight nodes

Full nodes validate transactions by downloading all transactions on the blockchain. In contrast, lightweight nodes keep a partial/essential list of blockchain transactions (mainly the block headers) rather than the whole transaction history. A full node can be set up on the cloud or run locally.

#### How to run a node

Running your own node is super simple:

1.  Choose a blockchain (e.g., Bitcoin, Ethereum, etc.).
2.  Download the client software of your preferred blockchain. The client will connect to all other peers/nodes/computers running the same client software and will copy the blockchain from them.

---

## Types of Blockchains

Blockchains are classified into two main types: **permissioned** and **permissionless**. However, there are several variations, with each serving a specific function. Let us take a closer look at each of them:

-   Private blockchains (Permissioned Blockchains)
-   Public blockchains (Permissionless Blockchains)
-   Hybrid blockchains
-   Consortium blockchains (Federated blockchains)

---

### Public blockchains (Permissionless Blockchains)

Public blockchains, also known as permissionless blockchains, are fully decentralized and open to the public. Any random person can add data and join the network as a node to participate in transaction validation and so on.

---

### Private blockchains (Permissioned Blockchains)

Companies that provide services frequently interact with third-party services, resulting in extended processing times. As a result, these businesses need a blockchain that is:

-   Private
-   Secure
-   Fully permissioned
-   Fast

This is where private blockchains come into play.

Unlike public blockchains, which enable anybody to be a node and interact with the network, private blockchains are fully permissioned and require each node to be validated before joining the network, allowing only a few authenticated individuals to become nodes and interact with the blockchain.

These types of blockchains are usually run by an authority known as the **trusted intermediate**, who has the power to alter the content of the blockchain.

Examples of private blockchains are:

-   Ripple (XRP)
-   Hyperledger
-   R3 Corda

---

### Hybrid blockchains

Hybrid blockchains are peculiar. Despite being permissioned or controlled, they offer freedom. You should have a good idea of what hybrid blockchains are if you've ever crossed a wolf and a man to create a werewolf.

Hybrid blockchains combine the features of both private and public blockchains. You must have a special invitation to access this database, and sometimes the blockchain members decide who to add to the blockchain. Still, it ensures transparency, freedom, and security. Some activities are kept private; whiles others are open to the public (only accessible by members of the blockchain).

---

### Consortium blockchains (Federated blockchains)

Consortium blockchains, like hybrid blockchains, are a mix of the two public and private blockchains. The only difference is that members from multiple organizations can collaborate on the networks instead of single individuals.

Consortium blockchains are essentially private blockchains with restricted access to organizations. This eliminates the need for a centralized control structure and is appropriate for banks working together to validate transactions.

---

---