Build a cpp-ethereum private chain

Source: Internet
Author: User
Tags git clone

(Small white One, can not find the information, the construction process is my own, if there are errors also please Haihan, thank you, at the same time, welcome to the big guys pointed out my flaws. )

Condition: Linux System (64-bit Ubuntu)

Cpp-ethereum Source

Ethconsole Console

1. Download source code from github, input in Linux terminal

git clone--recursive https://github.com/ethereum/cpp-ethereum.git

(if Git is not installed, you need to enter sudo apt-get install git, install git)

When the download is complete, enter

Cdcpp-ethereum

Go to the next good Cpp-ethereum folder.

2. Install CMake, and related components.

Input

sudo apt-get install CMake

sudo apt-get install Libboost-all-dev libleveldb-devlibcurl4-openssl-dev libmicrohttpd-dev Libminiupnpc-dev Libgmp-dev

3. Start to build

Enter it sequentially

mkdir build creates a building folder

The CD build goes into the folder that you created

CMake.. Generate a Build file (makefile)

Make build that build file

Make-j<number> number is the core of the execution

4. Install Ethconsole

First download NPM

Input

sudo apt-get install NPM

NPM install-g Ethereum-console

If there is no accident, there should be an error that cannot be installed, as follows

WARN engine servify@xxx:wanted:{"node": ">=6"} (current:{"node": "4.2.6"})

This is because NPM's default node version is too low and needs to be upgraded node

Execute the following command:

sudo npm install-g n

Think about the node version you want to install, and here is an example of installing version 7.10.0

sudo n stable 7.10.0

Input

Node-v

Detect if the installation was successful. Input

Ethconsole

As long as it doesn't appear

Ethconsole:command not found

That is, the installation was successful

5. Start to build a private chain.

Start by switching folders to ETH

CD ETH

(Write an episode, the ETH directory of the ETH is not complete, some commands do not, but given that we are operating through the console do not need to go through the ETH operation, it can not download the full ETH. )

Create a new JSON file under the ETH folder in the following format

{

"Config": {

"Chainid": 1000,

"Homesteadblock": 0,

"Eip155block": 0,

"Eip158block": 0

},

"Coinbase": "0x0000000000000000000000000000000000000000",

"Difficulty": "0x400",

"Extradata": "Oh my god!",

"Gaslimit": "0x2fefd8",

"Nonce": "0x0000000000000042",

"Mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",

"Parenthash": "0x0000000000000000000000000000000000000000000000000000000000000000",

"Timestamp": "0x00",

"Alloc": {}

}

This file is the configuration file for you want to create the world block, the meanings of each parameter are as follows:

Config.chainid//block chain ID, the--networkid parameter in the Geth command needs to be consistent with the Chainid value
Config.homesteadblock//Homestead hard fork block height, no attention required
Config.eip155block//EIP 155 hard fork height, no need to pay attention
Config.eip158block//EIP 158 hard fork height, no need to pay attention
Coinbase//Miner account, the first block will be dug up to give the miner account to send the reward of the etheric currency
Difficulty//difficulty value, the bigger the more difficult
Extradata//Additional information casually fill
The total consumption limit of gaslimit//gas is used to limit the sum of the transaction information that the block can contain, because we are the private chain, so fill the maximum
Nonce//A 64-bit random number
A hash generated by a part of the last block that is used to Mixhash//with nonce for mining.
Hash value of Parenthash//previous block
Alloc//Preset accounts and the number of etheric coins in the account, private chain mining is easier to not configure

Name the file Zero.json, which will be used later. Create a new folder under the ETH folder named Data0, which will be used to store chunk data.

Here are a few common ETH operations,

--help or-H: Show Help list

--no-discovery:eth default connection full node, through the input-no-discovery let our private chain not to link the whole node.

--genesis: The creation node usage of the initialization private chain is –genesis <filename>

--network-id: Your ID name, for a number, is consistent with the Chainid in your JSON file, and you will need to connect to other nodes later.

--datadir <filename>: The name of the folder you want to use to store the chunk data.

--private <name>: You create the name of the block.

--m <on/off/number>: On for you to allow mining, off for not allowed, number for you to specify a block.

...........

Enter the following:

./eth--genesis Zero.json--d data0–no-discovery-m On–network-id 1000

(If you have an error, try replacing the JSON file I gave above by using the system-supplied JSON file example)

Opening the DATA0 folder generates a file for the. IPC suffix. Remember the absolute path to this file.

Open a new terminal, enter Ethconsole + path, for example:

Ethconsole CPP-ETHEREUM/BUILD/ETH/DATA0/GETH.IPC

You can connect to your private chain. and is operated through Ethconsole. Note that when you close the mine, the connection will terminate automatically.

About the operation method of Ethconsole, and how to operate directly through ETH, the blogger will update later. Readers can either access

https://github.com/ethereum/homestead-guide/blob/master/source/contracts-and-transactions/developer-tools.rst# Ethereum-console

And

http://web3js.readthedocs.io/en/1.0/

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.