Build NEO Private Chain Fast with Docker Technology

robbie wang
NewEconoLabs
Published in
6 min readFeb 14, 2018

By Terry Liu@NEL

Do you want to know one of few public chains that support smart contract from its origin after you are interested in NEO and participated in NEO events ?

Do you always want to build your own private chain referring to NEO documentations but don’t have enough time to finish it or encounter obstacle s after just starting doing it?

Do you want to research NEO smart contract but the gas is too expensive on the mainnet and it’s troublesome to apply on testnet?

Do you want me to show my wealth? Hey, look, I have 1oo million NEO. Congratulations, you can also the above problems after reading this article. Please follow the author’s operations step by step. Every step is the log of the author’s successful operation, so please rest assured. We have preset many parameters in this documentation. In general, you can have 100 million neo and spend it as you please!

This article is meant for those who want to experience private chain. Its title is build private chain in 5 steps and have one million NEO in 7 steps.

If you want more detailed info or just experience building Cli nodes in a simpler and quicker way, please refer to:

https://github.com/NewEconoLab/neo-cli-docker

The following operations are mainly in Linux instructions.

l The first step, build Docker environment

l It’s recommended to refer to Docker official website:

l : https://docs.docker.com/engine/installation/ to build Docker environment.

Docker supports all systems including Linux、Windows、Mac. Linux is its native support.

The author uses CentOS 7.4 x64 as the experiment environment. Other systems are also Ok. Ultimately, Docker layers all use CentOS.

The server or virtual machine is recommended not to be less than 2u4G.

l the second step, reference the dockerfile compiled by the author to build the image of NEO Cli Docker.

Open CentOS terminal or use SSH and enter the following instruction.

docker build -t neo-cli:v0.3 https://github.com/NewEconoLab/neo-cli-docker.git#:dockerfile/privatenet

The above instruction will build scripts from the automatic application of private chain image. The main operations are as follows:

to build the image of CentOS Docker

to install dotnet sdk environment

to install leveldb-devel library needed by NEO.

to install github.

to copy the latest code of neo-cli from NEO’s official github.

to compile neo-cli with dotnet sdk.

to copy neo-cli-docker project from NEL’s official github.

to replace with preset private chain version config.json and protocol.json in neo-cli-doker project in the neo-cli root directory.

The third step, to install docker-compose-the orchestration tool of Docker’s official container to prepare for production of 4 bookkeeper node containers in one key.

enter and run:

sudo pip install -U docker-compose

pip uninstall urllib3

pip uninstall chardet

pip install requests

docker-compose –version

The fourth step, reference container orchestration template to produce the minimum 4 bookkeeper nodes container(actually 3 bookkeeper nodes still produce blocks) on NEO chain in one key.

enter and run:

cd /home

sudo yum -y install git

git clone https://github.com/NewEconoLab/neo-cli-docker.git

cp neo-cli-docker/dockerfile/privatenet/docker-compose.yml docker-compose.yml

docker-compose up -d

docker-compose ps

If it looks like this, it means the container with 4 bookkeeper nodes has been successfully initiated.(at this moment nodes are not started yet.)

The fifth step,enter containers one by one, initiate nodes, open bookkeeper wallet and initiate consensus.

enter and run:

docker attach cli0 enter the first container,and in sequence: cli1、cli2、cli3

This is the inner environment of the container.

cd /home/cli && dotnet neo-cli.dll /rpc initiate cli node

open wallet ./docs/neo_private_net_0.json

Open bookkeeper wallet and in sequence: neo_private_net_1.json、neo_private_net_2.json、neo_private_net_3.json

wallet password: 123456

start consensus

Lastly, remember to use special combination of keys:【Ctrl】+ (【P】->【Q】which means click 【Ctrl】and then click 【Ctrl】and 【Q】 in sequence,logging out doesn’t close the current container.

Operate other 3 node containers in sequence, won’t repeat it here.

After the last node is initiated, wait for a second, you can see the private chain has been started to run.

It can be seen, the main bookkeeper’s role is taken in turn.

l the private chain has been built here. The next 2 steps is the application of private chain.

The sixth step, check private chain’s running state through Cli jsonPRC api.

to install api test programs like postman.

request by using”get”

http://116.62.160.38:10332/?jsonrpc=2.0&method=getblockcount¶ms=[]&id=1

Of which the IP part needs to replaced with the actual IP of your computer or virtual machine.

Then you can see the total block numbers of the current private chain. If you want to check other information, please refer to NeoCli api documentation.

The seventh step, get the 100 million NEO out of the original blcok from the bookkeepers’ multi-sig wallet and transfer it into a non-bookkeepr wallet.

n build config.json and protocol.json files that connect the current private chain.

For config.json, please refer to:

{

“ApplicationConfiguration”: {

“Paths”: {

“Chain”: “ChainPrivate”,

“Notifications”: “NotificationsPrivate”

},

“P2P”: {

“Port”: 10333,

“WsPort”: 10334

},

“RPC”: {

“Port”: 10332,

“SslCert”: “”,

“SslCertPassword”: “”

}

}

}

For protocol.json, please refer to:

{

“ProtocolConfiguration”: {

“Magic”: 9726190,

“AddressVersion”: 23,

“StandbyValidators”: [

“0249b419692a17fb519c3b42ffbe82ae34855a45e54783a9bc940135b1c2753ece”,

“03298a54cdfb2b5ffae0638c60633de24e3956b76a44867475e81db5ce87b2a16b”,

“02b795b3322f0a171c7e7658371131c0caa77a9279818b85b9d0728a5a63452ff8”,

“0366440bd2a1fe4e0d1dcb9bf35995c5c6e858af846abef145064ab2b5e8ebfce8”

],

“SeedList”: [

“seed0.nel.group:10333”,

“seed0.nel.group:20333”,

“seed0.nel.group:30333”,

“seed0.nel.group:40333”,

],

“SystemFee”: {

“EnrollmentTransaction”: 1000,

“IssueTransaction”: 500,

“PublishTransaction”: 500,

“RegisterTransaction”: 10000

}

}

}

seed0.nel.group needs to be replaced with the actual ip of your computer or virtual machine.

n Download the bookkeeper wallet and non-bookkeeper wallet preset by the author.

Download https://github.com/NewEconoLab/neo-cli-docker ZIP

You can find relevant files in the /dockerfile/privatenet/docs

n Download NEO official GUI wallet. 2.6.0.0 above is recommended.

Replace config.json and protocol.json with the above content and run it.

Open neo_private_net_0.json number zero bookkeeper wallet. The password is 123456.

You can see there is 100 million neo in the contract address( feel exited?). this contract is a multi-sig address contract built by the four bookkeeper public keys. It needs at least 3 bookkeeper wallet signatures to transfer it out.

n the ultimate transfer out.

Build a new non-bookkeeper wallet. For example neo_private_net_test_0.json. Remember its address, for example,AWSuQXpjuY3v22gCbEFL2vHbSLMMVK1QD6

Open number zero bookkeeper wallet and click trade and transfer to the above address.

After clicking enter, it reminds there are not enough signatures.

it’s ok. We copy the whole content and open number one bookkeeper wallet. Click trad and sign to do the second person signature for this transfer.

copy output and open number two bookkeeper wallet. Click trad and sign to do the third person signature for this transfer.

At this time, broadcast button on the lower left appears, which means trade signature is completely ready.

100 million NEO will be transferred into AWSuQXpjuY3v22gCbEFL2vHbSLMMVK1QD6 you built after about 15 seconds.

GAS is produced continuously based on NEO holding through block production.

transfer to your own address. Then click advanced and withdraw neogas and you can withdraw the gas to your own address.

Now, you have a new NEO chain, 100 million NEO and countless gas. It’s time for you to show.

--

--