In my previous post, we started with a small NEO private net. Today, we will take a quick look into NEO-CLI and what it offers. Although it is named NEO-CLI, in practicality, this is a full blown NEO blockchain node instead of just a CLI tool to communicate with it. NEO offers two node types – GUI and CLI. I think the suffix comes from that and I wanted to explicitly mention it since it is a tad confusing.
At first, we will try to connect to our newly created private net. To do that, we will start with installing a separate installation of NEO-CLI. Installing NEO-CLI is pretty straight forward. You will need .Net core installed in your machine. If you don’t follow the instruction here.
Installation
I’m currently using an Ubuntu 16.04 as a reference OS. After installing .Net core framework you will need to install the NEO-CLI package. And since Im on a debian it was quite easy to do so the following way:
sudo apt-get install libleveldb-dev sqlite3 libsqlite3-dev
Configuration
We are testing and my local machine doesn’t have a frame of reference of the test private net we just created over Azure. To give this node a frame of reference we need to configure its SeedList to point to our own private net. What is a seed list? Simply put, it is nothing more than a list of URLs as described in the official NEO documentation. This is the first set of nodes NEO-CLI will try to connect to when it boots up.
To configure the aforementioned SeedList, we will modify the protocol.json
file, under the neo-cli
directory.
We need to update the SeedList section of the configuration the following way:
“SeedList”: [ "IP_or_FQDN_of_Azure_Private_Net_Host:20333” ],
If you opt to use the public test net, rename the protocol.testnet.json
to protocol.json
and you should be good to go.
Booting up the node
Now, it is time to start the node, we are going to invoke:
dotnet neo-cli.dll --log --nopeers
The log
option will log the smart contract information and nopeers
makes the node only connect to the seed nodes from the configuration file. this is something we want since this is a private network.
Creating a new wallet
Let’s create a new wallet then.
neo> create wallet mywallet.db3
NEO-CLI will ask for password twice for the wallet, pick your desired password. And copy the address and pubkey to keep it a safe place. If you forget the public key you can use list key
command to see it.
More on protocol.json
Before we end this one, we will have one last look at the protocol.json
configuration file for our node.
{ "ProtocolConfiguration": { "Magic": 56753, "AddressVersion": 23, "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" ], "RPCList":[ "http://127.0.0.1:30333" ], "SystemFee": { "EnrollmentTransaction": 1000, "IssueTransaction": 500, "PublishTransaction": 500, "RegisterTransaction": 10000 } }, "ApplicationConfiguration": { "DataDirectoryPath": "Chains/privnet", "NotificationDataPath": "Chains/privnet_notif", "RPCPort": 20332, "NodePort": 20333, "WsPort": 20334, "UriPrefix": [ "http://*:20332" ], "SslCert": "", "SslCertPassword": "", "BootstrapFile":"", "NotificationBootstrapFile":"", "DebugStorage":1 } }
- The
Magic
field contains auint
value that denotes the source network of the message. - The
StandbyValidators
field are the validating nodes in the private node. It is the list of public keys of aforementioned validating nodes. We created 4 wallet here in this specific example and thus we have 4 entries here. 4 is the minimum number of nodes here to be listed for reaching a consensus. SeedList
is configured to localhost in this example configuration since NEO-CLI is booting up against the localhost node.SystemFee
section is the section that defines the system fee. As the configuration states, the registration fee for assets is100000
GAS depicted by theRegisterTransaction
field.EnrollmentTransaction
field defines the registration fee for book-keepers.IssueTransaction
is the fee for distributing assets. Finally thePublishTransaction
is the fee for smart contracts.
That sums it up for this time. Next, we are going to have a look at how consensus works in NEO. And finally we will write a smart contract on NEO in C#. 🙂
One thought on “Neo Blockchain On Azure: Introduction to NEO-CLI”