How To Setup A Private Chain Of The NEO Blockchain

Private Chain is important for data privacy, permission control, as well as testing dApps and smart contracts. A private chain is an isolated copy of public blockchain which would run on your local machine. In this article, we’ll be going through the basic steps to run NEO private chain on a local machine and receive some initial NEO and GAS tokens.

Step 1

To set up the NEO private network (often called private-net), we have to install and configure Docker in the local system. If you’re using Windows 10 Pro, you can download Docker directly. For an older version of Windows, you need to install and configure the Docker toolbox.

Once Docker gets installed, start and run the docker. Then, open a command line or PowerShell and write the following command

Docker –v
 
This will display the version of Docker that has been installed in your system.
How to setup a private chain of the NEO Blockchain

Step 2

Pull the latest image using the following command.

docker pull cityofzion/neo-privatenet

Kindly note that the size of the image is a bit larger. So, it’ll take some time to download it.

Step 3

Once the image is pulled up, start the container using the command mentioned below.

docker run --rm -d --name neo-privatenet -p 20333-20336:20333-20336/tcp -p 30333-30336:30333-30336/tcp cityofzion/neo-privatenet

To check if the container is running or not, fire this command which will display the current running container(s).

docker ps
How to setup a private chain of the NEO Blockchain 

Step 4

Download the NEO-GUI wallet from here or use developer version (recommended for development) from here.

Step 5

Replace the content of the config.json file and protocol.json file with the following network details.

The updated config.json should look like this -

  1. {  
  2.       "ApplicationConfiguration": {  
  3.         "Paths": {  
  4.           "Chain""Chain",  
  5.           "Notifications""Notifications"  
  6.         },  
  7.         "P2P": {  
  8.           "Port": 20333,  
  9.           "WsPort": 10333  
  10.         },  
  11.         "RPC": {  
  12.           "Port": 30333,  
  13.           "SslCert""",  
  14.           "SslCertPassword"""  
  15.         },  
  16.         "DataDirectoryPath""ChainTestNet",  
  17.         "CertCachePath""Certs",  
  18.         "NodePort": 20333,  
  19.         "WsPort": 20334,  
  20.         "UriPrefix": [ "https://localhost:20332" ],  
  21.         "SslCert""",  
  22.         "SslCertPassword""",  
  23.       }  
  24.     }  

protocol.json

  1. {  
  2.         "ProtocolConfiguration": {  
  3.             "Magic": 56753,  
  4.             "AddressVersion": 23,  
  5.             "SecondsPerBlock": 15,   
  6.             "StandbyValidators": [  
  7.                 "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",  
  8.                 "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e",  
  9.                 "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699",  
  10.                 "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62"  
  11.             ],  
  12.             "SeedList": [  
  13.                 "127.0.0.1:20333",  
  14.                 "127.0.0.1:20334",  
  15.                 "127.0.0.1:20335",  
  16.                 "127.0.0.1:20336"  
  17.             ],  
  18.             "SystemFee": {  
  19.                 "EnrollmentTransaction": 1000,  
  20.                 "IssueTransaction": 500,  
  21.                 "PublishTransaction": 500,  
  22.                 "RegisterTransaction": 10000  
  23.             }  
  24.         }  
  25.     }  

Step 6

Run the neo-gui.exe installation package and check the connection between NEO GUI and the docker container. If you can see the number of connected nodes is 4, that simply means that the connection has been established successfully and the numbers represent the consensus nodes.

 
 How to setup a private chain of the NEO Blockchain

Step 7

Create a new wallet from NEO GUI Tool, go to wallet > New wallet database > input wallet name and password, it will generate a new wallet file for you. 

Step 8

Get some initial NEO and GAS by importing WIF key. Click to the black area > Import > Import from WIF > add key

KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr

How to setup a private chain of the NEO Blockchain 

Click OK, and check NEO and GAS balance you have!! We can use this NEO and GAS for smart contract execution.

 How to setup a private chain of the NEO Blockchain 

Conclusion

In this article, we’ve have seen how to setup NEO private network and got some initial NEO and GAS tokens. These we can use in testing smart contract over a local system. There are several other ways to configure it, however, the easiest one is using Docker.