Skip to main content

Command Palette

Search for a command to run...

Your First Step into Web3: What is Blockchain and Why It Matters?

If you have difficulties understanding blockchain and getting started, you are at right place. This post is designed to help complete beginners.

Updated
6 min read
Your First Step into Web3: What is Blockchain and Why It Matters?

Overview of what You’ll learn

  • In this article , we’ll go through the basics of what is actually is a blockchain and how it works. Why it matters?

  • We’ll start with motivation for building cryptocurrency, which fortunately is an easy thing to digest and also one of the best uses of blockchain technology.

  • Then we’ll go through jargon which are a little bit technical mainly hashing and proof of work.

  • Then we’ll understand why these things are necessary and start exploring how blockchain works.

Introduction : Why Cryptocurrency?

Problems with traditional Currency:

  1. Inflating Currencies- Currencies like US Dollar and Indian Rupees are not backed by any resource such as gold. Originally currencies were backed with gold and were just used as a contract for a certain amount of gold. Now if the government wants , it can take a loan and print currency depreciating its value.

    Below is a picture of how much currency US Government Prints-

  2. Bailouts- Bailouts happened many times where Government paid fines of Financial Institutions, pushing common people in huge financial difficulties.

    The most popular example is 2008 Wall street crash.

  3. Trust Based Model - The banking system we use is a trust based model where every transaction especially digital relies on trust . So it suffers the inherent weakness of that. There is a central Institution or Central Authority here.

These problems can be solved by decentralized money which is probably the best use case of Blockchain.

These problems motivated few cryptocurrency researchers to come up with Bitcoin in 2008.

Introduction to Hashing

Hashing is done through a mathematical function which takes an input of any size and produces an output of fixed length of characters. It is different from Encryption as a hash value can’t be reversed to find original input whereas an encrypted data can be decrypted.

Here are its properties-

  1. Deterministic: The same input will always produce the same output.

  2. Fast computation: The hash value can be quickly computed for any given data.

  3. Pre-image resistance: It should be computationally infeasible to reverse the hash function (i.e., find the original input given its hash output).

  4. Small changes in input produce large changes in output: Even a tiny change in the input should drastically change the hash output.

  5. Collision resistance: It should be computationally infeasible to find two different inputs that produce the same hash output.

It is analogous to a digital fingerprint of data. It is nearly unique to each data, it can’t be predicted , can be used as an identification and can’t used to find original data.

An example of a hash function is SHA-256. It is available in ‘crypto’ library of Nodejs.

It outputs a 256 bit string of characters(64 characters in hexadecimal).

Here’s a code snippet-

const crypto = require('crypto');//we are using the crypto library
const input = "100xdevs";
const hash = crypto.createHash('sha256').update(input).digest('hex');
//we are using createhash function with the hashing algorithm along 
//with the input data in update and encoding in digest
console.log(hash)
💡
A very important thing here to note is that if we can’t computationally find the input data to match a hash , we need to brute force through all possible inputs.This is called proof of work which we’ll understand later.

Here’s a Nodejs code to brute force through numeric inputs to find a hash that starts with 4 zeroes.

const crypto = require('crypto')
let i=0;
let firstfour;
let input;
do{



    input=i.toString(); //converting the numeric input to a string
    let output = crypto.createHash('sha256').update(input).digest('hex')
    firstfour=output.slice(0,4)
//splice function returns first 4 digits of the hash


     i++; //updating the input


}while(firstfour!='0000')

console.log(input)
💡
The data will always not be numeric. It will be definitely consist of text. Now we can serially go through numbers only in order. So for an input it must consist of a numeric part which can be adjusted to make the hash value follow a certain condition. That numeric part is called nonce.

We can easily modify the previous code to find the nonce for an input data

const crypto = require('crypto')
let i=0;
let firstfour;
let input;
do{



    input="demo data"+i.toString(); 
    let output = crypto.createHash('sha256').update(input).digest('hex')
    firstfour=output.slice(0,4)



     i++; 


}while(firstfour!='0000')

console.log(input)

Introduction to proof of work

  • Proof of Work is a kind of "puzzle" that computers must solve. The puzzle involves finding a special hash for data that meets specific criteria (e.g., it must start with a certain number of zeros).

  • The puzzle is intentionally hard to solve but easy to verify. Finding the correct hash requires trial and error, taking up time and computing power—this is the "work" in Proof of Work.

Description of how blockchain works:

We’ll take bitcoin’s working to understand how blockchain works.Although there are some differences in ethereum and solana , the general architecture stays the same?

  1. What is a Blockchain? It is a chain of blocks.

    Each block stores information about a particular transaction between users. Every user has a copy of all the blocks and no user can change a previous block. They can only add new ones

  2. If there are no central servers how does a user base work, who processes transactions?

    Rather than a server , there is a network of nodes.Each node is called a miner.

    No miner is in authority or no miner is superior. Each miner works simultaneously.

  3. If no miner is in authority who stores the information ?

    Every node on the blockchain.

  4. How do miners process transactions?

    💡
    A miner receives a data of a transaction , the particular block will contain block number , nonce , transaction data, and hash of previous output.
    💡
    They have to calculate the nonce, the nonce will be calculated based on the blockchain algorithm. The makers thought the hash has to always start from a particular number of zeroes .
    💡
    The number of zeroes will increase for increasing computation power of computers.
    💡
    After a nonce is calculated, the particular block is mined and broadcasted to all other nodes which they will re-verify before adding to their chain.
    💡
    At a particular time , multiple nodes can validate different blocks creating different versions of blockchain.

    One which is longer will win and be accepted by all.

    Here’s an illustration-

💡
NOTE: The above is a png. It will only be visible in light mode. Sorry for the inconvinience

Suppose T5 is calculated first , then the T5 will be added to chain and broadcasted to every body else.

💡
What’s the reason of including previous hash and doing so much proof of work? To protect against dishonest miners.

Consider these two blocks,

If some dishonest miner changes block 2 , then not only block 2 but block 3 will also be invalidated as there will be a change in previous hash

💡
So if a miner has to alter block 2 he has to re-mine all next blocks .For that he has to calculate all the next blocks earlier than every other miner.Means he has to own majority miners(51%), which is not practical.

Here’s an additional resource to mine yourself and learn-https://andersbrownworth.com/blockchain/

I am concluding it here. Hope you’re doubts are clear.I am happy to answer any questions you have ?

My contact- https://x.com/Sagni_kk

2

Well explained

L

Dexdert Net Pro has emerged as a true titan in the world of Bitcoin recovery, spearheading an unprecedented effort to help investors and businesses reclaim their lost or stolen digital assets. With a proven track record of success that spans over a decade, Dexdert Net Pro has established itself as the go-to expert when it comes to navigating the complex and often treacherous landscape of cryptocurrency theft and misplacement. Drawing upon his vast knowledge of blockchain technology and his unparalleled investigative skills, Dexdert Net Pro has developed a comprehensive, multi-faceted approach to recovery that has time and again yielded remarkable results for his clients. Whether it's tracking down the digital trail left by cunning cybercriminals, leveraging his extensive network of industry contacts, or employing cutting-edge forensic techniques, Dexdert Net Pro unwavering determination and innovative problem-solving abilities have allowed him to recover millions in Bitcoin and other cryptocurrencies that were previously thought to be lost forever. What sets Dexdert Net Pro apart is his deep understanding of the psychological and emotional toll that Bitcoin loss can take on individuals and organizations. He approaches each case with empathy and compassion, working tirelessly to not only recover the stolen funds but also to provide his clients with the support and guidance they need to navigate the complex legal and financial implications of their situation. His tireless efforts and uncompromising commitment to his clients' well-being have earned him a reputation as a true champion of the cryptocurrency community, a beacon of hope for those who have fallen victim to the perils of the digital financial landscape. As the demand for his services continues to grow, Dexdert Net Pro recovery remains steadfast in his mission to empower and protect cryptocurrency users, ensuring that the promise of financial freedom and security that Bitcoin represents is not undermined by the actions of those who seek to exploit it. With his proven track record of success and his unwavering dedication to his craft, Dexdert Net Pro stands as a shining example of the power of resilience, innovation, and unwavering determination in the face of adversity.

WhatsApp: +1 (435)294-8481

D

Cohort 3??🤔

S

Yeah.

A

Kudos!

R

Good content

K

Krazzzzzyyyy

The Chain Reaction: Path to web-3 mastery

Part 1 of 1

In this series, I will share my learning in web-3 in a structured manner so that any beginner starting to learn web-3 can use these blogs,docs and tutorials to start understanding and building.