Blockchain and Bitcoin are 2 different things:
Bitcoin is first decentralized digital currency, proposed by ‘Satoshi Nakamoto’ in year 2009. Bitcoin uses peer-to-peer technology to operate with no central authority or banks. Managing transactions and issuing of bitcoins is carried out collectively by the network, where as
Blockchain is the technology that enables moving digital coins or assets from one individual to another individual.
What is Blockchain?
A Blockchain is a decentralized, distributed and public digital ledger used to record transactions across many computers so that the record cannot be altered. A blockchain database is managed using peer-to-peer network and distributed time stamping server.
Block: Block holds the transaction data. Each block contains hash of previous block. This has the effect of creating a chain of blocks from first to current block.
Each network has its own defined block time, for ex in Bitcoin network time needed to generate and add a new block to chain is 10 minutes.
If anyone tries to tamper any block then it will change it’s hash value, and all the blocks following it are not valid.
Hash is also not enough because after tampering if all the blocks (blocks following the tamper block) are re-processed then chain will be valid again. So to stop this blockchain has concept of Proof Of Work.
Features of Blockchain:
- Distributed Ledger: Distributed ledger technology is a digital system in which transaction and their details are recorded in multiple places at the same time.
Unlike traditional databases, distributed ledgers have no central data store or administration functionality.
- Peer-to-Peer network: Peer to peer network is one in which two or more PCs shares files and access to devices. It maintain consistency of distributed ledger. There is no centralized database copy.
- Proof of Work(PoW): This is the most popular algorithm being used by currencies such as Bitcoin and Ethereum.In Proof of Work, in order for an actor to be elected as a leader and choose next block to be added to blockchain they have to find a solution to a particular mathematical problem.These actors are also known as miners. It is very hard to find a solution for given problem. Whenever a new block is mined, that miner gets rewarded with some currencies. Other nodes verify the validity of block by checking that hash of the block is less than a preset number (Every network has a global block difficulty, every block must have hash below this target).
Miners: Blockchain data is maintained at various nodes known as miners. Miners work is to use his resources to validate the block containing transactions and add it to chain.
Type of Blockchain:
- Public Blockchain: Public blockchain has no access restrictions. Ledgers are visible to everyone and anyone can verify and add a block of transactions to blockchain. For eg: Go Ethereum and bitcoin blockchain.
- Private Blockchain: Private blockchain is permissioned. One cannot join it unless invited by the network administrators. Only the invited people are allowed to verify and add blocks to chain, but everyone is allowed to view the ledger records.
- Consortium Blockchain: It is said to be semi-decentralized. Only group of organizations are allowed to verify and add blocks to chain, ledger can be open or restricted to group of peoples.
Blockchain use cases:
Issues with current banking system:
-> High transaction fees
-> Double spending
-> Frauds and account hacking
-> Financial crisis and crashes How blockchain solve these issues:
-> Decentralized System
-> Public Ledgers
-> Verification of every individual transaction
-> Low or no transaction fees
- Payment & Transfers:
-> No transaction fees
-> No bank account needed
-> Anonymity is maintained
- Healthcare: Use to store details of patients, this ensures that anyone who have access to blockchain can access the details of patients. This is highly secure, no one can access the details without knowing the persons public key and cannot make any changes.
- Law enforcement: Blockchain is highly secure way to maintain the details of crimes and criminals.
- Voting: Election requires authentication of voters identity, secure record keeping, tracking & counting votes without voter fraud, voters can vote from any place which will increase voter turnout.
- Real Estate
What is Genesis Block?
The Genesis block is the first block in the chain, the Genesis file is a JSON file that defines the characteristics of that initial block and subsequently the rest of the blockchain.
-> extraData: Extra 32 bit memory that you can use to pass any message.
-> difficulty: how difficult it would be to mine a specific block as part of that blockchain.
-> coinbase: coinbase is a address to which coins have to be send after the block has successfully been mined.
-> parentHash: Hash code of a parent block. As genesis block is the first block of the chain so it will be set to 0.
-> mixHash: It is a key value which will be kept same for your blockchain.
-> nonce: nonce is a key value that is computed by all miners
-> gasLimit: Limit of resource that one can spend to mining a block
-> alloc: Alloc defines the list of pre filled wallets
Combination of nonce and mixHash is known as Proof-of-work.
You need to get a specific hash value with a combination of nonce and mixHash which is less than the set value for a block, how this value is defined has a certain mathematical logic associated with that.
Basically we need to identify the value of nonce, once you add it to mixHash the value should be equivalent or lesser than the mathematical value set for that block. This is where resource gets invested, the value of nonce is something which you get by trial and error method.