Blockchain - Solana
Tags: blockchain, solana, beginners, web3
Published: 2023-07-07 14:00:42

In blockchain each block has **data, nonce, Hash, Previous black hash, and a block number.**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/es0wyf9gxckmm2n5mybu.png)

Each block is connected to previous block.🚃

Hash should always start from **4 zeros**, if not the block is invalid.0️⃣0️⃣0️⃣0️⃣

👉On changing data of one block, its previous block remain unaffected but next ones in sequence get affected.

Hash **depends on data, previous block hash and nonce of the block**.

There is **SHA algorithm** used for calculating hash.
Mining is a brute force method for getting the nonce value for a block.⚒️✖️➕➗➖


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmc8329qfsty2ore0s7l.png)

It is not possible for a hacker to change data of blockchain. Lets learn how its not possible. As you change value of block, hash changes and next block hash also changes. To make this hash start with four zeros, hacker has to find right nonce to validate this block, hacker mines to validate this block, change real data from this block and make this block corrupted and validate. 
To change one block, **hacker has to change all other blocks in sequence as after one block data changes, next block hash also change.**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxe5etgznqwfz73ymmbu.gif)



There are millions of block in blockchain. Hacker has to mine all blocks ahead of this block they are trying to change data of. It will take lots of resources and time to spend. 🤯🧠🧠

If this happens then here comes the term **distributed databases**.

Suppose we have two blockchains containing blocks, these are Peer A and Peer B. Both have same blocks. All peers have same blockchain in a peer to peer network, Peer is a individual computer here.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3lshfqe8gxdyeuu1ruy.png)

Suppose I write some random data on a block in a block chain. Hacker has to mine next block also and validate that also. One by one hacker validates all blocks of blockchain it made corrupt. But in both blockchain of different peer, the hash becomes different of different blocks. 😶‍🌫️
Earlier there were all same blockchain, same hash and data. Now as Peer B has different data than Peer A, say. How to find which is malicious. Now will check each Peer, check latest block data, compare its hash with other peer, and the majority of peer with same data are validate and original. Hence we find corrupted block. 🤨🚨

**Majority rules here.**🧑‍🤝‍🧑🧑‍🤝‍🧑
Kick out malicious blockchain network. Hacker can change one blockchain but not all peers.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bzofqr7gxsgeactzvmzr.gif)



Nonce is used to find block hash.

## Consensus Protocol⚖️

There are protocol to prevent blockchain from attack. 
When one tries to add new block they have to solve a mathematical problem. Miner add new block after solving math problem that takes hour. uses so much resources like GPU, hardware units, electricity.

Suppose Peer A adds new block. All peer run an algorithm, to find whether new block presented by Peer A is valid or not. If block is right, all peer add that block in blockchain, Peer A gets rewards, else, peer A is kicked out from network, no reward shared with it. 

It is consensus protocol or mechanism.

**Proof of history, Proof of stake** are some names.


Blockchain is immutable distributed and decentralized ledger. 

## SOLANA☀️


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3sg23umtsw3cq74v5b5n.gif)



What blockchain were present before solana?

Bitcoin - 2009
With bitcoin we can just send some currency from one point to other, no central authority, fully transparent.

Right now we first send request to bank, so bank is central party here.
Bitcoins when come into picture there is no central authority that comes when sending money from one party to other🏦❌🤝

**Ethereum **-> write programs into blockchain. It combines web application or programs, Solves many problems, like no central auth involved. No human interaction in processes. Problem is that its slow, doing anything like transaction, it takes time and high gas fee also.🤑💴

**Solana can do **_70~ transaction_** per second, while ethereum can do **_15-20 transaction_** per second in lesser fee than ethereum.**⚡⚡

## Why Solana?❓❓

Fastest blockchain right now, very secure, proof is history is their consensus algorithm, lesser fee.

Polka dot and Bitcoin are slower.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ed1wwnc8riko1mwdsxxt.gif)



Please hit like👍 and react 🤗 to this blog, make sure you comment💬🗨️ your views, corrections and remarks here.

thanks ❤️

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joqfeeav16n79hdr1o1w.gif)