Version
Show / Hide Table of Contents

Using NEO-CLI

The NEO-CLI client works as an normal node in the P2P network and meanwhile a cross-platform wallet handling various assets transactions.

NEO-CLI Security Policies

Caution

The exchange must use a white list or firewall to block external server requests; otherwise there will be a significant security risk.

NEO-CLI does not provide the function to remotely switching on/off the wallet, and it does not verify the process when opening a wallet. Therefore, exchanges should set their own security policies. The wallet must be kept open all the time to respond to the withdrawal requests of users. For security reasons, the wallets should be run in an independent server on which the firewall is configured properly, as shown below.

MainnetTestnet
JSON-RPC via HTTPS1033120331
JSON-RPC via HTTP1033220332
P2P1033320333
websocket1033420334

About NEO-CLI

NEO-CLI is a command-line client (wallet) for developers. Developers have two ways to interact with it:

  • Using the CLI (command-line interface) commands. For example, you can create a wallet, generate an address, etc.

  • Using the Remote Procedure Call (RPC). For example, you can transfer to the designated address, acquire the block information of the designated height, acquire the information of the designated trade, etc.

NEO-CLI provides the following features:

  • As a wallet, manages assets through the command-line.

    To enable the wallet,enter the following command under the NEO-CLI directory:

    dotnet neo-cli.dll 
    

    To check all the available commands, enter the following command:

    help 
    

    For more information, refer to CLI Command Reference .

  • Provides APIs to retrieve blockchain data from nodes. The interfaces are provided through JSON-RPC ,and the underlying communications use HTTP/HTTPS protocols.

    To start a node which provides RPC service, enter the following command under the NEO-CLI directory:

    dotnet neo-cli.dll --rpc 
    

    For more API information, refer to API Reference .

  • Provides transaction information of NEP-5 assets.

    To synchronize the NEP-5 assets log, you need only to install the ApplicationLogs plugin and turn on --rpc. For more information refer to NEO-CLI Installation .

#FunctionCommand
1Run NEO-CLI dotnet neo-cli.dll
2Open RPC and log the NEP-5 assets transaction information --rpc or -r or /rpc

You can enable multiple functions, for example, to enable all the above functions, enter the following:

dotnet neo-cli.dll --rpc --nopeers

Creating a Wallet

The exchange needs to create an online wallet to manage the deposit addresses of users. A wallet is used to store the information of the accounts (both public keys and private keys) and the contracts. It is the most important proof that the user holds. Users must keep the wallet files and the wallet passwords secure. They must not lose or disclose these data. Exchanges do not have to create a wallet for every address. An online wallet usually keeps all deposit addresses of users. A cold wallet (offline wallet) is another storage option which provides better security.

NEO-CLI supports wallets in two formats: the sqlite wallet (.db3) and the new NEP6 standard wallet (.json). For exchanges the sqlite wallet is recommended.

To create a wallet, do the following:

  1. enter create wallet <path> .

    <path> is the wallet path and wallet file name. The file extension can be .db3 or .json, depending on the wallet type you are using, for example, create wallet /home/mywallet.db3 . If the file extension is not specified, the NEP6 format (.json) is used by default.

  2. Set a password for the wallet.

Generating Deposit Addresses

A wallet can store multiple addresses. The exchange needs to generate a deposit address for each user.

There are two methods to generate deposit addresses:

  • When the user deposit (NEO/NEO GAS) for the first time, the program dynamically generates a NEO address. The advantage is that there is no need to generate addresses at fixed time intervals, while the disadvantage is that it's not convenient for backup.

    To develop the program to dynamically generate addresses, use the NEO-CLI API getnewaddress Method . The created address is returned.

  • The exchange creates a batch of NEO addresses in advance. When the user charges (NEO/NEO GAS) for the first time, the exchange assigns a NEO address to him or her. The advantage is the convenience to backup the wallet, while the disadvantage is the need to generate NEO addresses manually. To generate addresses in batch, run the NEO- CLI command create address [n] . The addresses are exported automatically to the address.txt file. [n] is optional. Its default value is 1. For example, to generate 100 addresses at a time, enter create address 100 .

Either way, the exchange must import the addresses into the database and distribute them to users. It is generally recommend the exchange use the second way, so as to reduce the external controls and run the wallet more stably.