Blockchain: A Comprehensive Beginner’s Guide

https://medium.com/thedarkside/blockchain-a-comprehensive-beginners-guide-8f1c0303286f?source=rss----c4037b4d8519---4

Ethereum Blockchain: A Comprehensive Beginner’s Guide to Understanding Concepts

Understanding the blockchain can seem challenging. In our journey to unravel this complexity, I’m placing a spotlight on a fundamental concept: the ‘world state.’ Why? Because grasping this concept serves as a cornerstone to comprehending the blockchain’s mechanics. I’ll strive for simplicity, aiming to make this exploration as friendly and straightforward as possible

While the concept of a ‘world state’ is primarily associated with Ethereum, this guide is here to help beginners understand important blockchain concepts, including Ethereum’s ‘world state.’ Let’s start by exploring the basics of blockchain together!

What is the World State?

The world state in Ethereum is like a snapshot of who has what (it’s not exactly that, but we’ll keep things simple for now ..)

For instance, imagine the world state as

SAMI has 1 eth, ZARATH has 1 eth.” ( eth is the currency, just like dollars )

This world state can change with a transaction. If SAMI sends 1 eth to ZARATH, then this is a transaction :

SAMI makes a transaction : { to : ZARATH ; value : 1 eth } ==> WORLD STATE

the world state will transform to :

SAMI has 0 eth, ZARATH has 2 eth.

In this example, the world state serves as evidence of ownership; if someone wants to know how much money (eth) ZARATH has, they access the world state and search in it. They will find this line: “SAMI has 0 eth, ZARATH has 2 eth.” And they will then conclude that ZARATH has 2 eth!

Addresses in the blockchain :

Actually, the world state doesn’t store names such as SAMI or ZARATH directly. Instead, each person, like SAMI and ZARATH, has an address — a unique 20-byte hexadecimal code allocated to them. an example of this address is: “0x620dE2FEA8fEAb1888E4d82e57B8b9C3401cC88d” (my own address)

For this guide, SAMI’s address would be : 0x11111111111111111111111.(keep it simple)

Similarly, ZARATH’s address : 0x22222222222222222222222.

Let’s go back to the world state :

it was previously recorded as “SAMI has 0 eth, ZARATH has 2 eth.” Now, let’s use their addresses instead of SAMI and ZARATH and update the world state :

The world state :

0x11111111111111111 :0 eth, 0x22222222222222222222 : 2 eth.”

Everything’s been smooth up until now, Shall we proceed?

Nonce :

Initially, the concept of the nonce wasn’t part of the original design but was introduced to tackle security vulnerabilities.

But what is a nonce? Quick response: it’s the number of transactions made by an address.

Let’s update the world state once more:

Remember, initially, SAMI and ZARATH both held 1 eth each. SAMI initiated a transaction, sending 1 eth to ZARATH. Since ZARATH hasn’t conducted any transactions, their nonce remains at 0. SAMI, having made 1 transaction, has a nonce set to 1.

The world state :

0x11111111111111111 : balance=0 eth, nonce=1

0x22222222222222222222 : balance=2 eth , nonce= 0.”

The balance refers to the amount of ETH held by an address.

Accounts :

this is an example of an account: “0x11111111111111111: balance=0 eth, nonce=1”

So The World State that we’re dealing with has two accounts, one for SAMI and the other for ZARATH.

the account is address + account state.

The address is the unique hexadecimal 20-byte code we’ve discussed earlier.

The account state, in turn, is ( the balance + nonce ).

TYPES OF ACCOUNTS :

What we covered earlier pertains to a distinct account type known as EOA (Externally Owned Account).

Another type of account exists known as a Contract Account (CA). The key distinction lies in the additional properties specific to the latter, which include code and storage, on top of the balance and nonce.

As the name implies, an “Externally Owned Account” (EOA) is managed by an external entity, such as individuals like SAMI and ZARATH.

EOAs are managed by private keys. These private keys are essentially secret codes held by individuals like SAMI and ZARATH (like the bank credentials of a person), allowing them exclusive control and access over their respective accounts.

Conversely, contracts are not under the control of external actors. But they are in control by the EVM (Ethereum virtual machine ) code that they have in their account state.

Don’t get me wrong here, individuals can still control contracts, but the process isn’t direct like in EOAs — they need to navigate through the code to exert control. More precisely, their interaction with the code occurs through the use of contract functions. If a function grants them control privileges, they effectively control the contract. However, if there’s no function providing such privileges, then they don’t — plain and simple.

Redefining The world State

definition:

The world state is a bunch of accounts! That’s it :

WORLD STATE! AGAIN :

So, the world state consists of multiple accounts (address + account state ), each being either an EOA with the account state (balance + nonce) or a contract in which the account state is (balance + nonce + code + storage). The world state changes when transactions are executed.

The key point is, a single transaction isn’t the whole story; transactions are collated into blocks. Multiple transactions come together in a block, and it’s this block that ultimately influences the world state.

in ETHEREUM for example: The block time is designed to be approximately 15 seconds.

Each 15 seconds, a new block of transactions comes to the world state and makes changes in it again :

This series of blocks is what we call the BLOCKCHAIN !!!

Consider this: the blockchain might as well be called ‘STATECHAIN.’ It’s essentially a continuous chain of evolving World States, each transforming after every block of transactions :

REFERENCES: https://github.com/takenobu-hs/ethereum-evm-illustrated


Blockchain: A Comprehensive Beginner’s Guide was originally published in The Dark Side on Medium, where people are continuing the conversation by highlighting and responding to this story.