In 2018, it was believed that most of the blockchain development technologies were divided into three architectures: 1.0, 2.0, 3.0, and today we are talking about Blockchain 2.0 technology Ethereum private chain building and Geth client use.
Installation of the Geth client
Installing using the installation package
Sudoapt-getinstallsoftware-properties-common
Sudoadd-apt-repository-yppa:ethereum/ethereum
Sudoapt-getupdate
Sudoapt-getinstallethereum
Use source code compile, build Golang environment
1. Download the Go Language installation package First wget
2. Perform sudotar-c/usr/local/-xzfgo1.8.3.linux-amd64.tar.gz decompression
3.VIM~/.BASHRC add exportpath= $PATH:/usr/local/go/bin then build the workspace directory under the/home directory and add the Go working directory exportgopath=/home/ Workspace, last SOURCE~/.BASHRC.
4.sudoapt-getinstallgit-y install git into workspace, build github.com directory, github.com directory to build Ethereum directory, execute ethereum in Gitclonehttps directory ://github.com/ethereum/go-ethereum.git
5.cdgo-ethereum Execution Makegeth
Create a private chain
Create an initial block
Vimgenesis.json
{
"Nonce": "0x0000000000000042",
"Config": {
"Chainid": 1123,
"Homesteadblock": 0,
"Eip155block": 0,
"Eip158block": 0
},
"Timestamp": "0x0",
"Parenthash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Extradata": "0x00",
"Gaslimit": "0x80000000",
"Difficulty": "0x10",
"Mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Coinbase": "0x3333333333333333333333333333333333333333",
"Alloc": {}
}
Initializing the Genesis block
Geth--datadir "Qkl"--networkid1123initgenesis.json
Enter the private chain
Geth--identity "Qkl"--datadir "Qkl"--networkid1123--rpc--port30303console2>>geth.log
Geth Some commands for the client
Account Operations
eth.accounts//View Account
personal.listaccounts//View Account
Personal.newaccount ("* * *")//New Account
Personal.unlockaccount ("**********")//Unlock Account
Personal.lockaccount ("**********")//Lock Account
Token operation
Eth.getbalance ()//view balance
Web3.fromwei ()//Unit conversion
Node operations
NET Module
net.listening//View node Status
net.peercount//View the number of node links
Admin Module
admin.nodeinfo//Viewing node information
Admin.addpeer ()//Add node
admin.peers//View information for the added node
ETH module
eth.hashrate//Viewing the hash operation rate of a node
Open and close mining
Miner.start (n)//n is the number of mining threads
Miner.stop ()
Some setup commands
Miner.setetherbase (Eth.accounts[n])//etherbase address does not need to be on this machine
Miner.setextra ("Zhou")//write some additional information
Eth.getblock (n)//view chunk information