Intro
In the mid-nineties, a paper titled "The Bitcoin White Paper" was published by the name of Satoshi Nakamoto, shortly thereafter cryptocurrency was launched, Nakamoto conducted the first-ever Bitcoin transaction & a programmer paid 10000 Bitcoins for two pizzas. The story of Blockchains origin, is one of the best of all dramatic stories that could ever happen in the tech world... who's Satoshi Nakamoto? Was it just a publicity stunt? or it was a revolutionary idea that could put the Revolutionarys in danger...? Many questions & none of them have any answers, not until now, who knows about the future!?
Digging out some historical facts, learning some more boring theory concepts, managing a bit hectic workday on Flutter...well, that was my Day-02 on Blockchain #100DaysOfCode. So, without any further ado, let's dive into it...
What is Blockchain
As we discussed yesterday, a public database is shared across many computers in a network, & yet there's a very tiny...close to impossible chance of forging the system. That kind of miracle is blockchain, it can revolutionize finance & many other industries, ensuring your assets guarantee & decentralization of power, i.e. it won't depend on powerful systems, and there won't be any monopoly unlike it is in the case of governments, banks & capitalists who can manipulate the market.
Internal Working of Blockchain
A macro-level explanation of how blockchain internally works:
The use of a hashing algorithm is at its core, whatever data we enter into the block, the algorithm generates a unique hash for it.
The block is divided into multiple parts like, id, nonce, data & hash, the id, data & nonce we enter are responsible for generating the unique hash.
Cryptography algorithms (SHA256 in our case) run all possible combinations of Nonce values along with the entered data to generate a hash with the first four digits being zero. The process is called the Mining of Blocks.
These blocks form a chain storing the previous block hash to establish a chain/reference. As the chain is interrelated changing any of the values results in the mining of all the blocks ahead, eventually forcing the expensive computation ahead. If the user still manages to do it & forge the data in the blockchain, then? then what? That could be a problem, that's where the Decentralization Peer-to-peer connection principle comes into the picture.
Peers participating in blockchain to run transactions each of them contain a copy of all the transactions a blockchain contains i.e. the state of the blockchain. This provides the blockchain with decentralization in turn prohibiting having authority in centralized power, instead giving equal power & responsibility to all peers.
Now if a user tries to manipulate/forge some data of blockchain on his device & somehow becomes successful in it, all other peers would still have a copy of the unchanged transactions blockchain, eventually, the malfunctioning peer will be removed from the chain.
This level of transparency & decentralization of power is something achieved from the blockchain principle.
This process is too expensive such that each transaction i.e. every data change causes some value i.e. some currency spending.
Whenever we do some transaction, a miner mines a chunk of transactions in a new block, & once it's complete the immutable block becomes the last chain block in the chain.
Miners play an important role in mining the transaction, without them the process of mining won't move ahead, for every transaction the user needs to pay some value/currency as fees to the miner.
The fees to be paid to the miner depend on multiple factors like Gas Limit, Gas Used, Extra Gas paid for prioritizing the transaction, and so on...
In every transaction some of the currency gets burnt during the process i.e. it neither gets transferred nor gets paid to the miner, it just gets lost or burnt.
For explanatory purposes the tutor uses the link Blockchain practical explanation, explaining the core of blockchain, though the actual implementation of blockchains could differ from this, at the very core of the conceptual level, this is how the blockchain works or at least I've understood it that way.
Some Important Terminologies on the Go
Though the explanation given is pretty explanatory, I do feel some of the concepts/terms are worth revisiting which I've tried explaining below,
Hashing: A Hash is a fixed-length string meant to identify a piece of data & they are created by placing said data into a hash function(hashing algorithm)
SHA256 is one of the algorithms used for creating a hash.
Block: A list of transactions mined together.
Mining: The process of finding a solution to the blockchain problem, which in our case is to make the first four digits to zero. Nodes get paid for mining the blocks.
Private Key: Private to the user only. It is used for signing a transaction.
Public Key: Accessible for everyone & is public. All users can verify if the transaction is valid & actually made by that particular user.
Transaction Fees: amount paid to the miner(developer running the smart contract on his node/machine) for processing the transaction request
Gas Price: unit of computational measurement, the more complex your transaction is, the more gas price you’ll need to pay.
Gas price * the gas used for a transaction = Transaction Fees.
Consensus: The mechanism used to agree on the state of the blockchain
In most cases like Ethereum & Bitcoin use something called Nakamoto Consensus
Chain Selection Algorithm: How to verify which chain is a true or original blockchain that is figured out or ruled by the Chain Selection Roule.
Sybil Resistance Mechanism: The process of mining blocks is the Sybil resistance mechanism. Each blockchain is working using either of the Sybil Resistance Mechanisms for mining
I. Proof of Work(PoW): consumes lots of electricity as every single node is running as fast as it can to win the rewards, doing expensive computations in shorter time & in speed to achieve eventually uses high GPU memory & higher electricity.
II. Proof of Stake(PoS): putting out something at stake that the node is going to fairly mine the block i.e. putting some Ethereum at stake. Here miners are actually called Validators
Outro
So far these are some of the learnings that I can share with you all, I've tried to put everything as per my understanding & there's a chance that I might've mistaken somewhere, so, feel free to correct me on anything in the comments.
Wrapping up my Day-02 of #100DaysOfCode, will catch up again tomorrow, till then, it's a farewell.