I've been watching an intro to blockchain and Solidity by freecodecamp.org on YouTube and would like to summarize some of the basic concepts laid down in the video
Hashing Function
There are multiple algorithms (implemented in functions) that can be used to produce a hash value from data.
Block
A block encapsulates data by including additional metadata. For now, lets look at two new pieces of metadata
- Block number - this is the primary key and blocks are ordered by this value
- Nonce - this is the value that has to be determined, and is implementation specific
In the following diagram, the specific blockchain implementation requires that a hash value starts with four zeroes. This varies depending on the implementation. Since both Block number and Data are immutable, the nonce is the only piece of data that can be altered to produce a hash value that starts with four zeroes.
Blockchain
Multiple blocks can be linked together. For this, another piece of metadata is added to the block -
- Previous Hash - This is the hash value that was produced in the block prior to the current one
With the introduction of the previous hash value, any update to an intermediate block will invalidate the current block's hash value, and this will require a re-computation of a new nonce. This in turn will require a re-compute of nonce values in all subsequent blocks. As the size of the blockchain grows, updates become increasingly difficult
Distributed
A blockchain is distributed and lives on multiple machines. This makes it nearly impossible to tamper with data in a block, since the hash values of a block on multiple machines would not match.
Attaching data to a blockchain is computationally intensive. This work is handled by miners - computers running the block chain software. The miner that successfully computes the nonce (proof of work that can be validated), is allowed to attach the data to the blockchain.
The incentive to perform the work is currency issued by the blockchain implementation - Bitcoin, ETH etc.
Writing data to a blockchain usually require transactions fees in the same currency