Basic Operations in Bitcoin Blockchain
Tags: bitcoin, blockchain, ethereum, web3
Published: 2022-08-28 17:59:00

We have all heard about Blockchain and how it solves many security and counter-party risks, being a decentralised and immutable digital ledger. This article mainly focuses on how the Bitcoin Blockchain (mother of all blockchains) implements these security measures and removes the need of a centralised intermediary for the transfer of value.

The main operations in a blockchain are `transaction validation` and `block creation` with the `consensus` of the participants. However, there are many underlying operations which help bitcoin solve the problem of [double spending](https://en.wikipedia.org/wiki/Double-spending).

Operations in the decentralised network are the responsibility of the peer participants and their respective computational nodes. These computational nodes can be a laptop, desktops, or server racks. These operations include validation transactions, gathering the transactions for a block, broadcasting the ballot transactions in the block, consensus on the next block creation, and chaining the blocks to form an immutable record.

### Basic Operation by a Node(Miner)
1. **Validation of Transactions** - A Blockchain validator performs validation by verifying whether transactions are legal (i.e. not malicious or double spends etc). This process involves validating more than 20 criteria, including size, syntax, etc., some of these criteria are - Referenced Input and [Unspent Transaction Output(UTXOs)](https://en.wikipedia.org/wiki/Unspent_transaction_output) are valid, reference input amount and output amount matched sufficiently. All the valid transactions are added to a pool of transactions - called [mempool](https://www.blockchain.com/charts/mempool-size)

2. **Gathering(grouping) Transactions** - Collecting transactions for a block. This grouping of transactions is done at an individual level. All the miners can independently group whatever transaction they want to choose for their candidate block. However, the miner's fees are the sum of all the transaction fees + block rewards using a [coinbase transaction](https://academy.bit2me.com/en/que-es-coinbase-transaccion/).

3. Broadcasting valid transactions & blocks - Once the miner has solved the mathematical puzzle, it broadcasts his selected block with the puzzle solution. 

4. Consensus on next block creation - The broadcasted block is then verified by all nodes at individual level.

*It may happen that two nodes transmit their blocks for the same block number after solving the mathematical puzzle. In that case every node will start working on top of the block which reached it first, and this results in the forking of blockchain. The forking of the chains usually completely resolves in 5-6 further blocks. Blockchain resolves this forking of chains by following a rule : **Largest chain is the most true version of the truth** and the largest chain is accepted by the nodes at individual level every time there is an ambiguity.*

5. Chaining Blocks - Once the block is selected, block is added to the local copy of blockchain at node level.

#### Bonus

- The algorithm for consensus is called proof-of-work protocol since it involves work i.e. computational power to solve the puzzle and to claim the right to form the next block. 
- **Transaction zero**, index zero of the confirmed block is created by the block's miner. It has a special UTXO and does not have any input UTXO. It is called the coinbase transaction that generates a minor's fees for the block creation.

To summarise, the main operations in a blockchain are transaction validation and block creation with the consensus of the participants. 
There are many underlying implicit operations as well in the bitcoin blockchain.
For more fine-grained details you can refer to [this] (https://smartereum.com/8970/how-do-bitcoin-nodes-verify-transactions/) article.