Reference article address: http://blog.csdn.net/sportshark/article/details/51855007
Build Environment: Ubuntu
Specific installation can refer to the official guide:
Https://github.com/ethereum/Go-ethereum/wiki/Building-Ethereum
One: Enter the Ubuntu terminal command line:
Enter separately:
sudo apt-get Installsoftware-properties-common
sudo add-apt-repository-yppa:ethereum/ethereum
sudo add-apt-repository-yppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install Ethereum
System networking After the completion of the command will complete the installation, after the installation, enter the Geth command, you can see the Geth started information (connected to the public chain). or enter Geth--help
If you are realistic about the various parameter prompts for the command line, the installation is successful.
Note: If there is an error during the installation, do not lose heart in the rush to give up, read its error message, and then fix it, and then continue the installation, generally error is due to the need to rely on other components, the first installation of other components.
II: Genesis BLOCK:
After the above installation is successful, direct start, you can connect the public chain. Now create a private chain by configuring the creation block. In the same network, the creation block must be the same, otherwise it cannot be unicom.
Create a ETH root directory folder that creates a new creation block JSON file Piccgenesis.json under the root directory. The contents are as follows:
{
"Nonce": "0x0000000000000042",
"Mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Difficulty": "0x4000",
"Alloc": {},
"Coinbase": "0x0000000000000000000000000000000000000000",
"Timestamp": "0x00",
"Parenthash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Extradata": "Secbroblock",
"Gaslimit": "0x0000FFFF"
}
Parameter explanation:
Mixhash is used in conjunction with nonce to excavate a hash generated by a portion of the previous block. Note that his and nonce settings need to meet the yellow paper of the etheric Square, 4.3.4. Block Header validity, (44) The conditions described in the section.
Nonce Nonce is a 64-bit random number used to dig mines, noting that his and mixhash settings need to meet the yellow paper of the etheric Square, 4.3.4. Block Header validity, (44) The conditions described in the section.
Difficulty the difficulty of setting the current block, if the difficulty is too big, the CPU digs the mine to be very difficult, here sets up the minor difficulty
Alloc used to preset accounts and account number of the etheric currency, because the private chain mining is easier, so we do not need to preset a currency account, when needed to create their own.
Coinbase Miner's account number, fill in
Timestamp set the time stamp of the Genesis block
Parenthash the hash value of a block, because it is a Genesis block, so this value is 0
Extradata additional information, casually fill in, you can fill in your personality information
Gaslimit This value sets the total consumption limit of gas to limit the sum of the transaction information that the block can contain, because we are the private chain, so fill in the maximum.
Switch to the directory where you just stored Piccgenesis.json: Execute the following command:
basepath=$ (CD ' DirName $ '; pwd)
Get the current directory
Geth--datadir "$basepath/chain" Init Piccgenesis.json
Create data store address and initialize Genesis block
Geth--identity "Piccetherum" –rpc--rpccorsdomain "--datadir" $basepath/chain "--port" 30303 "--rpcapi" db,eth,net, Web3 "--networkid 95518console
Command explanation:
Parameter Name parameter description
Identify the chain of identity blocks, fill them out, and use them to indicate the name of the current network
INIT specifies the location of the creation block file and creates the initial block
DataDir sets the location of the current block chain network data storage
Port Network listening ports
RPC initiates RPC communication, which enables deployment and debugging of smart contracts
RPCAPI sets the client that allows the RPC to be connected, typically DB,ETH,NET,WEB3
Networkid sets the network ID of the current block chain to differentiate between different networks, a number
Console starts command line mode and can execute commands in Geth
Startup success is as follows:
After the node is started, the Geth command line mode is entered, and the input personal.newaccount () will give you a new account if prompted to enter the password.
Third: Connect other nodes:
Five: Connect to other nodes:
First to know your own node information, in the Geth command line interface to enter commands, attention to case
Admin.nodeinfo
The system will show
Enode: "enode:// 1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84 b62d742@0.0.0.0:30303 "
which
enode:// 1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84 b62d742@0.0.0.0:30303
Is the information of their own nodes, pay attention to the "0.0.0.0" into your own IP. Send this information to the other node and enter it on the command line of the other node:
Admin.addpeer (' enode:// 1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84 b62d742@192.168.1.101:30303 ')
If the addition succeeds, the input admin.peers displays the newly added node.
Six:
The command to begin mining:
Miner.start ()
End Ore Digging:
Miner.stop ()