Blockchain Basics | Installation | go-ethereum | go Language | Linux
After the Successful Completion of Blockchain Specialisation, it is time to distribute my knowledge with people.
While reading this blog & following the steps will lead you guys to the Blockchain Technology Platform.
Basic Key Points:
The blockchain technology supports methods for:
- a decentralized peer-to-peer network
- a collective trust model among unknown peers
- a distributed immutable ledger of records of transactions.
Decentralization means the network operates on a user-to-user (or peer-to-peer) basis.
A Distributed Immutable Ledger means the data doesn’t sit on one all-powerful server and the data stored in it cannot be deleted or edited
Transactions bring about the transfer of value in Bitcoin Blockchain. The concept UTXO defines the inputs and outputs of such a transaction.
Once a block is verified and algorithmically agreed by the miners, it is added to the chain of blocks,
viz., the blockchain.
Steps For Blockchain Installation
‘
Step -1 Clone Git repository
viraj@thinksprout:~$ git clone https://github.com/ethereum/go-ethereum
Step -2 Get into go-ethereum Folder and View the Files
viraj@thinksprout:~$ cd go-ethereum/
Step -3 Check for Latest version of go-ethereum
viraj@thinksprout:~/go-ethereum$ git tag
0.2.2
0.3.0
0.3.1
0.5.13
…………………….
Step -4 Today's latest version is v1.9.9. Since v1.9.9 is the latest version of GO-ETHEREUM, we will go with it. So we will create a branch for our GO-ETHEREUM.
viraj@thinksprout:~/go-ethereum$ git checkout tags/v1.9.9 -b MyBank
Switched to a new branch ‘MyBank’
check your branch:
viraj@thinksprout:~/go-ethereum$ git branch
* MyBank
SVs_Bank
master
Step -5 Before moving to blockchain execution we need to install Go Language.
Download the go language from :
https://golang.org/dl/
After Downloading the file go to particular directory
Extract the File using Administrator
viraj@thinksprout:~/Downloads$ sudo tar -xvf Filename.tar.gz
Move the ‘go’ to usr/local/
viraj@thinksprout:~/Downloads$ sudo mv go /usr/local
Add Environment Variable using to LINUX system
viraj@thinksprout:~$ sudo gedit .bashrc
Now add the following line at end of .bashrc file
export GOROOT=/usr/local/goexport GOPATH=$HOME/projects/myproexport PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Save the file and close it.
Now use the command to Restart the .bashrc file.
viraj@thinksprout:~$ source .bashrc
Check for go language has successfully install.
viraj@thinksprout:~$ go version
go version go1.14.4 linux/amd64
Step -6 Execute make all
It will tell GIT to build the target file as per the input.
viraj@thinksprout:~/go-ethereum$ make all
It will take some time.
Step -7 Create a Genesis Block
It is referred to as 1st Block or 0th Block for a blockchain. It Basically contains details with respect to blockchain
In go-ethereum Folder create new folder ‘genesis’
viraj@thinksprout:~/go-ethereum$ mkdir genesis
Create the .json file which has all details of genesis block
viraj@thinksprout:~/go-ethereum$ cd genesisviraj@thinksprout:~/go-ethereum/genesis$ gedit genesis3.json
Add the following code in genesis3.josn
{“nonce”: “0x0000000000000042”,“mixhash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,“difficulty”: “0x400”,“alloc”: {},“coinbase”: “0x0000000000000000000000000000000000000000”,“timestamp”: “0x0”,“parentHash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,“extraData”: “0x”,“gasLimit”: “0xffffffff”,“config”: {“chainId”: 10,“homesteadBlock”: 0,“eip155Block”: 0,“eip158Block”: 0,“eip150Block”: 0,“eip150Hash”: “0x0000000000000000000000000000000000000000000000000000000000000000”}}
Step -8 Now, for starting the Blockchain, we need to execute the following command
viraj@thinksprout:~/go-ethereum/genesis$ /home/viraj/go-ethereum//build/bin/geth — datadir ~/ethereum/net3 init /home/viraj/go-ethereum/genesis/genesis3.jsonviraj@thinksprout:~/go-ethereum/genesis$ /home/viraj/go-ethereum//build/bin/geth — datadir ~/ethereum/net3 — networkid 3 console
Commands to Execute on Blockchain
- Creates a new account with specific wallet attach to it
personal.newAccount()
2. shows the total accounts available on the blockchain
eth.accounts
3. shows the number of block you are at. It changes when mining operation in done successfully
eth.blockNumber
4. Starts the mining operations
miner.start()
5. Stops mining operations
miner.stop()
6. Get Balance of particular account
eth.getBalance(account no. Hash value)
Now, we have successfully Implemented the Blockchain setup & basic operations of Creating account & Wallet, Mining operations, Checking Balance, Checking Block number, etc.
References:
- http://www.coursera.org/
- Images: https://unsplash.com/
- Idea credits: https://thinksproutinfotech.com/
For any quires reach me at:
Thinksprout Infotech
Nanded City, Pune
411041.
Website: https://thinksproutinfotech.com/
Email: shelarvs11@gmail.com