Installing the system environment
Note: This article operates in a Mac environment.
1. Install go environment (go requires version 1.7 and above)
- The MAC executes the command brew install go.
Encountered by the wall problem, you can open the browser https://studygolang.com/dl/golang/go1.10.3.darwin-amd64.pkg download, and then step by step installation.
- Configure the GOPATH environment variable. Execute the following command in turn:
Execute CD ~
Implementation of VI. Bash_profile
Insert a line of your own project directory address in. Bash_profile Export gopath=/
Sers/edz/go
Execute Go ENV
If the output has the same Gopath value as set above, it is set successfully.
1.jpg
2. Configuring the C Compiler
- Mac side performs brew install GCC
compiling source files
- Download Project Source Https://github.com/truechain/truechain-engineering-code
- Enter the project directory. To compile. Execute command: Make Getrue
- After the compilation is complete. The path to the Getrue command is the project directory/build/bin/.
- Add the Getrue path to the system environment variable
3.jpg
Getrue command
Getrue--help View command Help,
4.jpg
Genesis.json
Create your own test network. You first need to create the network's Genesis state, so that all nodes know and agree to this state.
The Genesis state (or Genesis block) is a small JSON file. Such as
2.jpg
简单介绍一下这个genesis.jsonchainId 链的IDalloc 系统自带的两个地址及余额coinbase 矿工工号difficulty 挖矿难度extraData 扩展字段gasLimit 交易手续费nonce 随机字符串,用于挖矿mixhash 配合nonce进行挖矿parentHash 上一个区块的哈希timestamp 区块生成的时间
Build a test network
Step1. Set up the test directory. For example, test
Step2. Refer to the source code in the Cmd/getrue Genesis.json file, the contents of the file are as follows.
{ "config": { "chainId": 10, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "alloc" : { "0x970e8128ab834e8eac17ab8e3812f010678cf791" : { "balance" : "90000000000000000000000"}, "0x68f2517b6c597ede0ae7c0559cdd4a84fd08c928" : { "balance" : "10000000000000000000000"} }, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x200", "extraData" : "", "gasLimit" : "0x2fefd8", "nonce" : "0x0000000000000042", "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00"}
Step3. Create a Genesis block. Execute the following command
Getrue--datadir Test Init Path/to/cmd/getrue/genesis.json
The--datadir is used to specify the directory. When the above command finishes, the directory has more than Getrue and KeyStore two folders. Getrue folder is used to store the relevant data of the chain, KeyStore folder is stored in the chain of user information
Step4. Start the test chain start node. Execute the following command
Getrue--datadir Test--nodiscover console 2>>getrue.log