Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Setup Your Private Blockchain with NEO

0.00/5 (No votes)
31 Jan 2019 1  
How to setup your private Blockchain with NEO

Introduction

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.

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.

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.

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).

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

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:

{  
  "ApplicationConfiguration": {  
    "Paths": {  
      "Chain": "Chain",  
      "Notifications": "Notifications"  
    },  
    "P2P": {  
      "Port": 20333,  
      "WsPort": 10333  
    },  
    "RPC": {  
      "Port": 30333,  
      "SslCert": "",  
      "SslCertPassword": ""  
    },  
    "DataDirectoryPath": "ChainTestNet",  
    "CertCachePath": "Certs",  
    "NodePort": 20333,  
    "WsPort": 20334,  
    "UriPrefix": [ "https://localhost:20332" ],  
    "SslCert": "",  
    "SslCertPassword": "",  
  }  
}  

protocol.json

{  
    "ProtocolConfiguration": {  
        "Magic": 56753,  
        "AddressVersion": 23,  
        "SecondsPerBlock": 15,   
        "StandbyValidators": [  
            "02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",  
            "02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e",  
            "03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699",  
            "02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62"  
        ],  
        "SeedList": [  
            "127.0.0.1:20333",  
            "127.0.0.1:20334",  
            "127.0.0.1:20335",  
            "127.0.0.1:20336"  
        ],  
        "SystemFee": {  
            "EnrollmentTransaction": 1000,  
            "IssueTransaction": 500,  
            "PublishTransaction": 500,  
            "RegisterTransaction": 10000  
        }  
    }  
}

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.

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. 

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

KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr

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

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here