setting up a private chain environment based on Ethernet square
Through the methods and scripts in this article, we can quickly build their own private chain for block chain development test, this article based on the Ethernet workshop technology to build, divided into two parts, one is the Ubuntu under the building method, the other is windwos under the construction method,
One, install Geth client under Ubuntu
Ubuntu is used because the official side of the ether is good for Ubuntu and is the easiest to install on each Linux system.
Geth Official Installation Guide:
Https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum
Go to the Ubuntu command line and execute the following command
sudo apt-get update
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
After the system network is implemented, the installation of the Ethernet square client is completed, including Geth,bootnode, EVM, Disasm, rlpdump,ethtest
At this point, if you enter the Geth command, the start of the Ethernet scene will appear
Second, install Windows under the Geth client
Windows must be 64-bit system, download the compiled Win64 client from the official website, unzip it to run, download the following address:
https://github.com/ethereum/go-ethereum/releases/
After downloading, there is only one Geth.exe file.
Install the image client mist, still download the compiled client from the official address, download the address:
https://github.com/ethereum/mist/releases/
After downloading decompression, Ethereum-wallet is the graphical interface of the ether square.
Iii. preparing for the creation of the World block document
Configuration of their own creation block is to distinguish the public chain, the same network, the creation of the world must be the same, otherwise not unicom, this method in Windows and Ubuntu under the general.
New file Piccgenesis.json, enter the following and save
{
"Nonce": "0x0000000000000042",
"Mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Difficulty": "0x4000",
"Alloc": {},
"Coinbase": "0x0000000000000000000000000000000000000000",
"Timestamp": "0x00",
"Parenthash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"Extradata": "0x888",
"Gaslimit": "0xFFFFFFFF"
}
Explain the function of each parameter:
Mixhash |
A hash produced by a part of a block that is used to excavate a mine with nonce. 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 |
The number of etheric coins used to preset accounts and account numbers, because the private chain mining is relatively easy, so we do not need to preset a currency account, when needed to create their own. |
Coinbase |
The miner's account, just fill in. |
Timestamp |
Set the time stamp of the Genesis block |
Parenthash |
The hash value of the previous block, because it is a Genesis block, so this value is 0 |
Extradata |
Additional information, casual fill, you can fill in your personalized information, if the latest Geth initialization may be prompted to start with 0x, you can fill in the "0x00" or "0x123888" and so on. |
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. |
Four, start the private chain node
Start Geth that can start the block chain of the etheric square, in order to build the private chain, need to add some parameters in Geth startup, geth parameter meaning as follows:
Identity |
Block chain of the mark, casually fill in, to mark the current network name |
Init |
Specify the location of the creation block file and create the initial block |
DataDir |
Set the location of the current block chain network data |
Port |
Network Listening port |
Rpc |
Initiate RPC communication for deployment and debugging of smart contracts |
Rpcapi |
Set up clients that allow RPC to be connected, typically DB,ETH,NET,WEB3 |
Networkid |
Set the network ID of the current block chain, used to differentiate between different networks, is a number |
Console |
Start command line mode, you can execute commands in Geth |
1, in the Ubuntu Start block chain node
Under Ubuntu, first switch to the directory you want to run, the directory should have a configured Piccgenesis.json file, 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 "0x888"--rpc--rpccorsdomain "*"--datadir "$basepath/chain"--port "30303"--rpcapi "DB,ETH,NET,WEB3" --networkid 95518 Console
After the start of the interface as follows, the cursor rests on the last command line, you can execute the Ethernet square command.
I0707 00:45:43.680087 ethdb/database.go:82]alloted 128MB Cache and 1024 file handles to/home/lihe/desktop/chain/chaindata
I0707 00:45:43.726008ethdb/database.go:169] closed db:/home/lihe/Desktop/chain/chaindata
I0707 00:45:43.728913 ethdb/database.go:82]alloted 128MB Cache and 1024 file handles to/home/lihe/desktop/chain/chaindata
I0707 00:45:43.908795 ethdb/database.go:82]alloted 16MB cache and file handles to/home/lihe/desktop/chain/dapp
I0707 00:45:43.969506 core/genesis.go:92]genesis block already in chain. Writing canonical number
I0707 00:45:43.980337 Eth/backend.go:274]successfully wrote custom Genesis block : 6e92f8b23bcdfdf34dc813cfaf1d84b71beac80530506b5d63a2df10fe23a660
I0707 eth/backend.go:184]protocol versions: [00:45:43.980618], network id:95518
I0707 00:45:43.981567core/blockchain.go:204] Last header: #81 [6193c4b0 ...] td=10836704
I0707 00:45:43.981645core/blockchain.go:205] Last block: #81 [6193c4b0 ...] td=10836704
I0707 00:45:43.981677core/blockchain.go:206] Fast block: #81 [6193c4b0 ...] td=10836704
I0707 00:45:43.985253 p2p/server.go:313]starting Server
I0707 00:45:45.834488p2p/discover/udp.go:217] listening,enode:// 134881790e54c803955715e3661c27f91caaf499be813e29c9f986e2eac62d47e02b13a8e51776c1caea554655614ed26ce0185d84e626da7ac48a83a 60113ff@[::]:30303
I0707 00:45:45.835853 node/node.go:366]http Endpoint opened:http://localhost:8545
I0707 00:45:45.848008 p2p/server.go:556]listening on [::]:30303
I0707 00:45:45.849731 node/node.go:296] Ipcendpoint opened:/home/lihe/Desktop/CHAIN/GETH.IPC
Welcome to the Geth JavaScript console!
Instance:geth/v1.5.0-unstable/linux/go1.5.1/piccetherum
Coinbase:0x93509a2f4b2b974b07ef0b52e07c3992601f5de1
At block:81 (Tue 2016 21:02:25CST)
DataDir:/home/lihe/Desktop/chain
modules:admin:1.0 debug:1.0 eth:1.0 miner:1.0net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
>
You can see a hint that listening on [::]:30303 and welcome to the Geth JavaScript console!, indicating that it has started successfully
Note: If you want to use Ubuntu as a permanent block chain node, when using the Nohup command, the Geth startup parameter console must be removed or the Geth will automatically stop.
2, in the Windows boot block chain node
Enter the directory under Windows Geth, place the configured Piccgenesis.json file, and execute the following command:
Geth--datadir "%cd%\chain" Init Piccgenesis.json
Create data store address and initialize Genesis block
Geth--identity "0x888"--rpc--rpccorsdomain "*"--datadir "%cd%\chain"--port "30303"--rpcapi "DB,ETH,NET,WEB3" Networkid 95518 Console
When you see a hint that listening on [::]:30303 and welcome to the Geth JavaScript console!, it has started successfully
v. Create accounts using nodes
After the startup node succeeds, it enters the Geth command line mode and enters the following command
Personal.newaccount ()
You will be prompted to enter your account password and confirm that a newly generated account will be displayed at the end of the system.
Six, connect 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 "
&n