Place under win7 Ethernet environment to build private chain + development + building integrated development environment (To be continued)

First, under win7 Ethernet environment to build Place

1.geth installation
geth is referred Go Ethereum project is the use of a written language Go Square Ethernet client software, users can interact with through the geth Square Ethernet network, the completion of mining, preparation of contracts and other functions. geth following installation steps:
(Geth installation is recommended to establish a separate folder to save, for example, I created a folder Ethereum in the D drive, the following continue to set up geth folder, then most of the ether Square relevant documents will be operating in these folders)
① Open https://geth.ethereum.org/downloads/ download the Windows version of geth clients:

 

 

 
② Open download directory to find geth.exe file, double-click execution:
 
③geth installation is complete (this step is almost not a problem, if you encounter problems searchable resolve itself, it will not be difficult)
 
2. Configure Go locale
Square Ethernet application development is based on the Go language, so you want to configure Go locale in the environment. As used herein choco command-line installation, so first need to install additional choco:
① Open cmd.exe, copy the following command:

 

 

 
② waiting line installation choco (chochlatey)
Input command choco ③ After installation is complete, to give the successful installation of FIG interface:

 

 

 
These are installed choco, as a preparatory Go language installed, followed by Go environment configuration:
① Open cmd.exe, execute the following command:
C:\Users\Administrator> choco install git 
C:\Users\Administrator> choco install golang 
C:\Users\Administrator> choco install mingw
(Because my machine already installed, so not for display)
② This step is very simple, generally will not go wrong, if you encounter problems can be resolved.
 
3.Ethereum installation
① into Ethereum files created folder
② enter the next instruction, make online copy the files under ethereum github.com to local ethereum folder, create a new folder go-ethereum:
git clone https://github.com/ethereum/go-ethereum
③ Enter the next instruction, enter the local go-ethereum folder:
cd go-ethereum
④ enter the next instruction, use go get install golang installation package:
go get -u -v golang.org\x\net\context
[Climax coming! ! ! The following section is a tutorial no other issues involved (others may have not encountered this problem, of course, I hope you will not encounter T ^ T)]
The following error message appears after you enter this statement:
......unrecognized import path "golang.org\x\net\context"......

 

 

Why is this problem?
Because your PC can not visit the true Internet.
 
So then solved how to use common methods to complete the installation:
① we have to understand that, technically considered, the instruction can not be executed due to golang.org can not obtain, so long as it can obtain the installation package
② find the root of the problem enough to start. Learned from the big picture of God, in fact, created a mirror image library golang on github, https: //github.com/golang/net the image library that is https://golang.org/x/net
In other words, you want to pass command golang.org \ tasks can be accomplished instead https://github.com/golang/xxx.git
③ so we apply their knowledge, input command:
go get https://github.com/golang/x/net/context.git
⑤ But I am more tragic is that before the use of such a method is not modified, so take a lot of detours, still the middle repeatedly prompted the wrong path, which is very crash, but still slowly troubleshoot the problem. . . So I think, is not a need for a separate installation package separately? For example, golang have, then x is not no? So I execute:
https://github.com/golang/x.git
And then prompts:
fatal:destination path 'x' already exists and is not an empty directory
That family has been in existence, so I went down to find net.git, remains the same reply, and then I find context.git down, or the same result:
 

 

 

 

This time I seem to understand something. . . Before the Internet to find a lot of tutorials with instruction go get -u -v golang.org \ x \ net \ context, but does not work well for me, so I use the command go get https://github.com/golang after /x/net/context.git time instead of actually been installed successfully, but I used the front of this command to verify that the validation fails, so I always thought that was a mistake, but in fact now success.
To further prove my installation was successful, I went back to try the test command:
go install -v
Findings and results of others is exactly the same, this case really completely at ease ~ ~ ~
 
These are the Ethernet environment to build Place, aims to build a private Ethernet Square chain, so that the latter can operate in private DApp chain.
 
Second, build a chain of private Ethernet Square
The first part is the basis for all subsequent operations, the next step is followed by a first part build private chain.
① establish a file in your favorite location convenient folder, such as D: / Ethereum / examples / shall_scripts / test /
② into this folder, create a file test.json
③ Open test.json file, and populate it with the following:
 
{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "coinbase" : "0x0000000000000000000000000000000000000000",
    "difficulty" : "0x40000",
    "ExtraData": "",
    "gasLimit" : "0xffffffff",
    "nonce" : "0x0000000000000042",
    "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp" : "0x00",
    "alloc": { }
}
 
[Explain] field
config defined block may be affected and the consensus protocol, generating the back block creation will be set according to the configuration block
(Config in particular, particular attention is chainid, represents the block chain network number, when the number 1 indicates that the public chain, so here we can simply set a number greater than 1, it was suggested that greater than 10 and no explanation, so welcome A friend challenged);
coinbase and generated new block at the same time there is a special transaction records, this is the right to obtain a new block billing account node, that is coinbase;
difficulty degree of difficulty of
extradata additional data
timestamp timestamp
The maximum gasLimit current block count allows the use of force
(Because we have established that the private chain, so do not count force to consider the issue, so here it is set to the maximum force count);
nonce random number
mixhash a set their own hash value and the nonce used to bind, thus proving successful mining
Hash value parentHash front block
alloc there should be filled and pre-set account balance, but we do not need here, so you can set to null
 
④ save the file test.json
⑤ open cmd terminal into the storage position D test.json file: / Ethereum / examples / shall_scripts / test /
 
⑥ Enter the following command to initialize test.json file:
geth --datadir test_data init test.json
(This instruction indicates, for test.json file is initialized, initialization resulting correlation data stored in the folder test_data)

 

 

 

 

⑦ displayed above chart means that successful initialization, such as if the words fatal appear, indicating test.json individual file syntax error or a lack of required fields, you can go online to view the correction method is very simple not to repeat them here.
Next, enter the command, open chain Ethernet Private Square:
geth --datadir test_data --networkid 666 console
 
【note! ]
a. The command indicates, open square Ethernet private chain into the console, a series of operations performed thereafter log log will be recorded in test_data folder. So, test_data here is the one above instructions test_data! Do not longer a separate folder, I was initially set up another new folder cause behind the failure of mining. . .
b. networkid number indicates that the network is not very familiar with, as also mentioned in test.json file, so the second issue is the need for additional attention test.json file chainid followed behind number and serial number must be the same here ! ! !
 
⑧ the following into the console interface for success, that's the private chain of the opening process, the next step is how to use the private chain a series of configuration settings and then start mining friends ~
 
⑨ input command:
eth.accounts
Shown below, represents the current node has no account, so we first step is to create an account
 
10. The input command:
personal.newAccount("123456")
Number in parentheses is set their own password, private chain calculation to obtain a unique address based on your account password, as shown below:
 
 

 

 

11. Next we try command again:
eth.accounts
It found that there has been a new generation of account
12. Because there is no new account balance, so we can look at the balance of the current account:
eth.getBalance(eth.accounts[0])
eth.getBalance (eth.coinbase)
eth.getBalance("xxxxxxxxxxx")

 

 

Three kinds of instructions can be successfully expressed Balance:
The first is similar to an array of high-level languages, because now there is only one account, so naturally occupy that accounts [0] position, if we can create a new account and then replace the figures in brackets;
The second is coinbase in place, because the node only has an account, so the account will automatically default to coinbase, of course, the latter may also want to replace, you can access instruction to replace coinbase self;
The third is the most direct way, in front of quotes is generated address, fill into it.
Balance inquiries after the discovery of instruction is 0, then the next step is to make money mining
 
13. The input command:
miner.start()
If the above is correct, then mining can be carried out smoothly, the following interface will display:
 
After about 14 seconds to stop mining instruction can enter the following:
miner.stop()
 
15. We then returned again look Balance:
eth.getBalance (eth.coinbase)
But also to re-look at the way the new generation of block:
eth.blockNumber
 
Mining ended, the money in the account, you can trade up, I went back to learn from, no problems, come and record ~
 
 
Although Ethernet Square, only appeared in 2014, but have to say much good people everywhere, online method also quite a lot of detail, but I may be due to improper operating system or lack of knowledge lead to very "strange" error will only able to explore on their own, so write down their own exploration experience, is that those who plant trees shade, detours.
 
If inappropriate, please correct me warm

Guess you like

Origin www.cnblogs.com/shall1995/p/11578976.html