Blockchain development (i) building a private chain environment based on Ethereum Go-ethereum

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.


After learning from various sources, we decided to start building a private chain environment based on Ethereum Go-ethereum. Because my computer system for WIN8, in order to avoid the window environment too many inexplicable problems, deliberately through the VM built a ubuntu16.04 version of the virtual system. The following are based on the ubuntu16.04 system.



Go-ethereum Client



Download Address & Reference Manual



First, you can look at the address of the Go-ethereum project on Git:
Https://github.com/ethereum/Go-ethereum

You can click on the Wiki tab on the item, or you can access the wiki via the address:
Https://github.com/ethereum/Go-ethereum/wiki/Building-Ethereum



Choose the installation instructions for your Ubuntu system on the wiki page, or you can access the following links directly:
Https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu



Ubuntu under install command



Open a command-line window, or use the shortcut key ctl+alt+t, and then enter the following command to install successfully:


sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo add-apt-repository -y ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install ethereum


PS: If you need to rely on other components during installation, install the other components first. Also, in the ubuntu16.04 version, the sudo apt-get install command can be streamlined to sudo apt install.



Installation test



After the installation is complete, enter it at the command line:


geth--help


If the actual command line various parameter prompt information, then the installation is successful.



Genesis Block



After the above installation is successful, the public chain can be connected by direct start. Now create a private chain by configuring the creation block. The same network, the creation of the block must be the same, or can not be connected.



Create a ETH root directory, creating 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:


Parameter name parameter Description
mixhash
nonce nonce is a 64-bit random number for mining, note that his and Mixhash settings need to meet ethereum yellow paper, 4.3.4. B Lock Header Validity, (44) The conditions described in the section.
difficulty Set the difficulty of the current block, if the difficulty is too large, the CPU mining is difficult, here set a smaller difficulty
Alloc
coinbase The miner's account, just fill it out.
timestamp set the timestamp of the Genesis block
parenthash
extradata
gaslimit


Start a private chain node



Parameters required to start the private node


Parameter name parameter Description
Identity The name of the blockchain, which is used to mark the current network
Init Specify the location of the Genesis block file and create the initial block
DataDir Sets the location of the current blockchain network data storage
Port Network Listening port
Rpc Initiate RPC communication to deploy and debug smart contracts
Rpcapi Sets the client that allows RPC to be connected, typically DB,ETH,NET,WEB3
Networkid Sets the network ID of the current blockchain to distinguish between different networks, which is a number
Console Start command line mode, you can execute commands in Geth


Start



The directory where I started the ETH is:


/home/zhuzs/eth


In this directory, put the created block JSON file that you just configured: Piccgenesis.json



So execute the following command directly:


Geth --Identity "Secbro Etherum " --RPC --Rpccorsdomain "*" --DataDir "/home/zhuzs/eth/chain" --Port "30303" --Rpcapi "DB,ETH,Net,web3 " -- Networkid 95518 Console --Dev 


PS: According to your own environment for the corresponding replacement. Note that the –dev is added at the end, and will be used later when the service starts successfully.



See the output instructions to start successfully, and to use the private chain:



This is followed by a related command operation, which is further explained in the next blog post.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.