The central idea of using a blockchain is to let people, in particular, people who don't trust one another share valuable data in a secure, tamper-proof way. In this article, I will explain to you how the blockchain works.
Terminologies in the Blockchain technology
These terms will help you understand how the blockchain works
The Block in the Blockchain
This is the core of blockchain records and keeps track of transactions in a digital ledger. Think of blocks as a box that contains some data and multiple of these blocks are put together to form a blockchain. In the same analogy, the blockchain can be imagined as a container that holds multiple boxes. A Blockchain will store these transactions in groups of blocks. Each record of the transaction will have an address(their wallet public key) of the person sending the transaction, the person receiving the transaction, the amount being sent, the time, and a unique hash. The Genesis Block is the very first block upon which additional blocks in a blockchain are added, You could think of it as a period of history.
The Chain in the blockchain
This comes in because the blocks are linked cryptographically together with the hashes. The current block will have the hash of the previous block and the next block will have the blockchain of the previous block and so on. If anything is changed on the block, the other block becomes invalidated. The generation of hashes for each block is cloned by unique mathematical puzzles that clone each block needs to be solved to verify if it is a real block.
A hash
A hash is very important to understand here. Blockchain technology uses hashing and encryption to secure the data, relying mainly on the SHA256 algorithm to secure the information. The hashing function makes an Input and then scrambles it to an output that is hard to decode.
This functionality allows a level of anonymity on the Blockchain since your name won't be revealed in the ledger but rather a hash of your wallet that stores your cryptocurrencies and NFTs.
Proof-of-Work
Proof of Work requires the people who own the computers in the network to solve a complex mathematical problem to be able to add a block to the chain. Solving the problem is known as mining, and ‘miners’ are usually rewarded for their work in cryptocurrency. Proof-of-work is the mechanism that allows blockchain cryptocurrencies to come to a consensus, or agree on things like account balances and the order of transactions. This prevents users from "double spending" their coins and ensures that the blockchain is tremendously difficult to attack or manipulate.
In a Blockchain, each block consists of 4 main headers:
- Previous Hash: This hash address locates the previous block.
- Transaction Details: Details of all the transactions that need to occur.
- Nonce: An random number given in cryptography to differentiate the block’s hash address.
- Hash Address of the Block: All of the above (i.e., preceding hash, transaction details, and nonce) is transmitted through a hashing algorithm. This gives an output containing a 256-bit, 64-character length value, which is called the unique ‘hash address.’ Consequently, it is referred to as the hash of the block. Numerous people around the world try to figure out the right hash value to meet a pre-determined condition using computational algorithms. The transaction completes when the predetermined condition is met. To put it more plainly, Blockchain miners attempt to solve a mathematical puzzle, which is referred to as a proof of work problem. Whoever solves it first gets a reward.
Proof of Stake
Proof of stake is a type of consensus mechanism used to validate cryptocurrency transactions. With this system, owners of the cryptocurrency can stake their coins, which gives them the right to check new blocks of transactions and add them to the blockchain.
Miners
Miners create new blocks on the chain through a process called mining. In a blockchain every block has its own unique nonce and hash, but also references the hash of the previous block in the chain, so mining a block isn't easy, especially on large chains. When a block is successfully mined, the change is accepted by all of the nodes on the network and the miner is rewarded financially.
Nodes
One of the most important concepts in blockchain technology is decentralization. No one computer or organization can own the chain. Instead, it is a distributed ledger via the nodes connected to the chain. Nodes can be any kind of electronic device that maintains copies of the blockchain and keeps the network functioning. Every node has its own copy of the blockchain and the network must algorithmically approve any newly mined block for the chain to be updated, trusted, and verified. Since blockchains are transparent, every action in the ledger can be easily checked and viewed. Each participant is given a unique alphanumeric identification number that shows their transactions.
How the blockchain actually works?
This is how Blockchain works: When a user creates a transaction over a Blockchain network, a block will be created. Once a block is created, the requested transaction is broadcasted over the peer-to-peer network, consisting of computers, known as nodes, which then validate the transaction. A verified transaction can involve digital assets like cryptocurrency, contracts, records, or any other valuable information. Once a transaction is verified, it is combined with other blocks to create a new block of data for the ledger. Whenever a new block is created, it is added to the existing Blockchain network. In the blockchain, each block contains some data, the hash of the block, and the hash of the previous block.
Each block In the above image contains some data(transaction data) which includes a hash, a timestamp of when the block was created and added to the blockchain, and the hash of the previous block. The previous block hash links the blocks together and forms a chain of data known as the blockchain.
Since every block has the hash of the previous block, it is impossible to modify any block without changing the entire chain so If an anonymous attacker removes, adds, or modifies any transaction in the 1st block, the HASH will change and since the 2nd block is chained to the 1st, the hash will be invalidated and that applies to every block of the chain. So if a block is under attack, it will then declare the chain invalid.
##Who manages and verifies the Blockchain?
If the Blockchain had one major service provider like Amazon web services. Blockchain wouldn't be secure right? So the Blockchain maintains a state of consensus by having an open network of nodes(let's just call this a server) that anyone can join and where everyone hosts a copy of the transaction and verifies the blocks. This is very cool because it adds an extra layer of security and also creates immutability meaning once an asset is being deployed to the Blockchain it cannot be edited or deleted.
##Conclusion We have come to the conclusion that each block created on the blockchain should contain a digital signature(hash), a timestamp, and other important, relevant information. It should be noted that the block doesn’t include the identities of the individuals involved in the transaction. This block is then transmitted across all of the network's nodes, and when the right individual uses his private key and matches it with the block, the transaction gets completed successfully.