Blockchain is a rapidly spreading technology which enables you to store records and information in a secure and decentralized manner. Blockchain makes it almost impossible for everyone to modify, corrupt or delete information. It is based on peer to peer network allowing everyone to contribute and share information on a distributed network secured with public key cryptography and shared ledgers. According to some Technology Futurists, Blockchain is going to be the backbone of the new internet in next coming years.
From varying perspectives, Blockchain has a lot of advantages and disadvantages
- Blockchain is not controlled by any single authority, its decentralized.
- Information written on its blocks can’t be corrupted or deleted.
- Blockchain is a lot more secure than traditional record keeping systems.
- Blockchain maintains its transparency by the use of distributed ledgers.
- Cryptocurrencies don’t need any third party (e.g, Banks) to verify the transaction, making it cost effective.
- Cryptocurrencies are the best payment option for crime dealers because of its anonymity.
- Currencies based on Blockchain are extremely volatile.
- Cryptographic puzzles consume a lot of processing power to compute hashes.
- Because of its complexity, Blockchain is not easy to understand and implement.
Applications of Blockchain
From Economy to Healthcare, Blockchain can be applied on diverse range of areas in business and technology. Existing economy and banking solutions are time-consuming and costly while cryptocurrencies are the best efficient, anonymous and cost-free alternative. Blockchain can also be applied to variety of other areas like Healthcare, Record management, Land registries, Payment processing, IoTs (Internet of Things), Voting systems etc.
Deploying your own Private Ethereum Blockchain
Blockchain is a complex topic and is difficult to learn from theory, so why not deploy our own Private Blockchain based on Ethereum for our Proof of concept. You can configure your own Private Blockchain on local network of PCs or Cloud (Amazon, Azure etc) but here we are going to use an Ubuntu machine for this purpose. If you wanna use Cloud, you need to just run an Amazon or Azure instance.
In this example, we’re going to create our own new and separate Ethereum Blockchain and this Blockchain will not interact with main Ethereum Blockchain and its nodes. So here we can set our own rules and configurations. You’ll need to install geth and Ethereum packages. The easiest way is adding Ethereum repositories and installing these packages using apt. Type
sudo add-apt-repository -y ppa:ethereum/ethereum sudo apt update && sudo apt upgrade sudo apt install ethereum -y
Now generate Authority and Transaction accounts using geth. Type
geth --datadir .ethereum/ account new geth --datadir .ethereum/ account new
Copy these addresses for later configurations. Now we’ll create and configure a Genesis Block using a CLI tool puppeth. Genesis Block is the first block in the blockchain and its configuration file is generated in JSON format which defines characteristics for the rest of Blockchain. In Genesis configurations, we can set our mining rules, consensus and ChainIDs.
Now that we’ve configured our Genesis Block and saved our configurations as “genesis.json”, we are ready to start our Private Node using the configuration file. To view and edit configurations, type
ChainID is an integer value that was introduced almost a year ago to prevent replay attacks on Blockchain.
Difficulty value is the difficulty required to mine a hash. For Public Blockchains, it should be high but for Private purposes we can set it to low for faster mining and transactions.
Timestamp is set by miners, however there are certain rules to protect this so that miner can’t manipulate it.
GasLimit is the highest amount of Gas that you’re willing to pay for your transactions whether they are successful or not.
Alloc is used to pre-fund some accounts in ETH.
Smart Contract is self executing program which defines rules in Blockchain without needing a middle man
Now we can initialize our Blockchain service. Run
geth --datadir .ethereum/ init genesis.json
geth --nodiscover --networkid 42 --datadir .ethereum/ --unlock 0x7a6b358b6ab43f0e2309405245aac129f273f72b --mine --rpc --rpcapi eth,net,web3 --rpcaddr [your_local_ip_address]
Some Helpful Commands
To start miner with n threads:
To stop miner:
To set Gas Price:
To send Transactions:
To check Balance:
To get Block Info:
Now that you have an idea how Blockchain works and how you can setup your own. You can join other PCs or Virtual machines together as nodes to make a Blockchain network. You can integrate mobile or web applications with Blockchain and generate your own crypto tokens and cryptocurrencies but this would be the first step towards building your own Blockchain Network.