I will try in this article to make it easy to understand how a Block is added to a Blockchain.
But first, what is the Blockchain?
A Blockchain is a database to record the transactions of a digital asset and is meant to make the history of that digital asset unalterable and transparent through the use of decentralization and cryptograpic hashing. And as it can be simply guessed it consists of a chain of Blocks.
What are Blocks?
A Block is simply a bunch of transactions and is formed by people called miners to get cryptocurrency as a reward.
How is a Block formed?
When a transaction is made , it is not added straight away to the blockchain. It has to go first to a transaction pool (memory pool). And here comes the role of a miner whose job is to pick transactions from the memory pool and gather them into a "candidate block" and try to add it to the Blockchain.
It looks like an easy task, but it is not... Let's see why?
When a Block is added to the Blockchain?
A Block is added to the Blockchain when a miner, who uses special software, solves the incredibly complex math problem of finding a nonce that generates an accepted hash which means a hash below a certain target value.
A lot of technical words...
What does a hash means?
Hashing means processing the data from a Block through a mathematical function (the hash function), which results in an output of a fixed length. This output is called the hash.
The data to be hashed includes the transactions gathered by the miner and some metadata (version, last block, Merkle root which is a fingerprint of all the transactions in the block, time and target) and the nonce.
What is the target?
The target is a value set by the network. It is calculated from the difficulty.
What is the difficulty?
The difficulty is a value set by the network to regulate how difficult is to add a Block of transactions to the Blockchain. The greater is the difficulty, the lower is the target value which makes finding a hash below this target more difficult.
What is the nonce?
Miners actually hash the block header with an extra number called the nonce which is an arbitrary number used by the miners to get a block hash below the target value and thus be able to add their "candidate block" to the Blockchain.
I hope this will help you understand in a better way how a Block is added to a Blockchain.
Talk to you soon.