CLI Command Reference
Open the command line, navigate to the directory where Neo-CLI is located, and enter the following code to start the command line wallet (i.e. the Neo node).
dotnet neo-cli.dll
This section will introduce all the commands in the command line wallet. You can manipulate your wallet with commands for creating a wallet, importing and exporting of private key, transferring, starting consensus, etc.
Overview
The following tables list all the commands. You can also enter help
in the command line to view them all.
All the commands described in this document conform with these conventions:
-
<>
indicate a parameter. -
[]
is for optional parameters. -
|
separates multiple parameters where any one of them can be used at your choice. -
=
indicates the default value of the optional parameter without an input.
Console Commands
Command | Description |
---|---|
version | Shows the current software version |
help [plugin-name] | Help menu, which can also show plugin related commands. |
clear | Clear screen |
exit | Exit program |
Contract Commands
Command | Parameters | Description |
---|---|---|
deploy | deploy <avmFilePath>...<contractDescription> | Deploys a contract |
invoke | <scripthash> <command> [optionally quoted params separated by space] | Invokes a contract |
Wallet Commands
Command | Parameters | Description |
---|---|---|
create wallet | <path> | Creates a wallet file. |
open wallet | <path> | Opens a wallet file. |
close wallet | Closes the current wallet. | |
upgrade wallet | <path> | Upgrades old wallet files. |
rebuild index | ||
list address | lists all the accounts in the wallet. Need to open wallet. | |
list asset | Lists all assets in the wallet. Need to open wallet. | |
list key | Lists all public keys in your wallet. Need to open wallet. | |
show utxo | [id|alias] | |
show gas | Lists all the GAS in your wallet. Need to open wallet. | |
claim gas | [all] | |
create address | [n is a positive integer and defaults to 0] | Creates address / batch create address Need to open wallet. |
import key | <wif|path> | Imports a private key / bulk import of private keys. Need to open wallet. |
export key | [address] [path] | Exports private keys. Need to open wallet. |
send | <id|alias> <address> <amount>|all [fee=0] | Sends assets to the specified address. Need to open wallet. |
import multisigaddress | <m pubkeys> | Creates a multi-signature contract. Need to open wallet. |
sign | <jsonObjectToSign> | Signs the transaction. The parameter is the json string that records the transaction information. Need to open wallet. |
Node Commands
Command | Parameters | Description |
---|---|---|
show state | Displays the current status of blockchain synchronization. | |
show node | Displays the address and port of connected nodes | |
show pool | [verbose] | Displays the transactions in the memory pool (These transactions are in the state of zero confirmation). |
relay | <jsonObjectToSign> | Broadcasts the transaction. The parameter is the json string that records the transaction information. |
Plugin Commands
Command | Parameters | Description |
---|---|---|
plugins | Lists loaded plugins | |
install | [Plugin name] | Installs the specified plugin |
uninstall | [Plugin name] | Uninstalls the specified plugin |
export block[s] | [path=chain.acc] | Exports the whole blockchain data. The exported data can be used for offline synchronzation. |
export block[s] | <start> [count] | Exports a specified number of block data from the specified block height. The exported data can be used for offline synchronization |
Advanced Commands
Command | Description |
---|---|
start consensus | Starts consensus |
Command Description
deploy
Deploys a contract on the blockchain.
Syntax
deploy <avmFilePath> <paramTypes> <returnTypeHexString> <hasStorage (true|false)> <hasDynamicInvoke (true|false)> <isPayable (true|false) <contractName> <contractVersion> <contractAuthor> <contractEmail> <contractDescription>
Parameters
-
avmFilePath
: Contract path. -
paramTypes
: Parameter type passed to the main function. -
returnTypeHexString
: Data type returned. -
hasStorage (true|false)
: Whether to use a storage. -
hasDynamicInvoke (true|false)
: Whether to make a dynamic call. -
isPayable (true|false)
: Is the contract address payable. -
contractName
/contractVersion
/contractAuthor
/contractEmail
/contractDescription
: contract related information.
Example
invoke
Invokes a contract.
Syntax
invoke <scripthash> <command> [optionally quoted params separated by space]
Parameters
-
scripthash
:Contract hash to invoke. -
command
:Method name in the contract, which can be followed by input parameters separated by space.
Example
create wallet
Creates a wallet file in the .db3 or .json format. A wallet password is required to be specified during the process.
Syntax
create wallet <path>
Example
The wallet file is generated under the neo-cli root directory. If you want to set other path, you need to create the folder in advance.
open wallet
Opens the wallet file at the specified path. The wallet password is required to be entered when opening the wallet.
Syntax
open wallet <path>
Example
upgrade wallet
Upgrades the old .db3 wallet file into the .json format.
Syntax
upgrade wallet <path>
Example
rebuild index
This command is used to rebuild the wallet index, which forces the wallet to sync up transactions from the block height of 0. Rebuilding the wallet index is not for a newly created wallet but for the cases when you import a private key or the assets in your wallet is not displayed properly.
Additionally, in the event that the transaction in your wallet is not confirmed for some reason, but the assets have already been deducted and this is not confirmed by the whole blockchain, you can remove the unconfirmed transaction to show the asset amount correctly by rebuilding the wallet index.
show utxo
Lists the UTXO of the specified assets.
Syntax
show utxo [id|alias]
Example
show gas
lists all the unclaimed GAS in the current wallet.
Syntax
show gas
Example
This command does not show the GAS that has been claimed. Use
list asset
instead.
On Neo3, The GAS in an account is claimed automatically every time when the number of Neo in the account changes.
claim gas
Claims available GAS in your wallet. The execution is carried out by a special Claim Transaction. The client will print the Claim Transaction ID after you enter the command.
After executing claim gas
, you will find GAS has been increased in the result of list asset
.
Syntax
claim gas [all]
Parameters
all
:Claims all the available GAS in the wallet. If not specified, GAS from the first 50 addresses in the wallet is claimed.
create address
Creates a new address. One can also enter create address 100
to create 100 new addresses in batches; Addresses are automatically exported to the address.txt file.
Syntax
create address [n]
Parameters
n
:Number of addresses to create. N is an integer and defaults to 1.
Example
export key
Exports private key of the address to the specified file. The command also requires the verification of the wallet password.
Syntax
export key [address] [path]
Parameters
-
address
:Address to export private key. -
path
:Path to the file used to store the private key.
Example
Exports the key to the console:
Exports the key to the specified file:
import key
Imports a private key, or import a file with a number of private keys.
Syntax
import key <wif|path>
Parameters
wif|path
:The key to import or the file path.
Example
If there is a specified file, the file is in the private key format. Refer to export key key.txt output.
import multisigaddress
Creates a multi-party signed address.
Syntax
import multisigaddress m pubkeys...
Parameters
-
m
:m is the minimal number of signatures. For example, creating a multi-party signed address with two public keys, m can be 1 or 2. -
pubkeys
:Public keys of multiple parties involved.
Example
send
Transfers the asset to the specified address. The command requires the verification of the wallet password.
Syntax
send <id|alias> <address> <amount>|all [fee=0]
Parameters
-
id|alias
:asset ID or asset abbreviations, e.g. neo,gas -
address
:payment address -
amount|all
:transfer amount -
fee
:This parameter can be left empty, and the default is 0. Setting a fee improves the transaction priority.
Example
Transfers 100 NEO to the address “AMwS5twG1LLJA4USMPFf5UugfUvEfNDz6e”:
If you are not sure of the asset ID, you can enter list asset
to view all assets in the wallet.
In above example, we can also replace the asset ID with asset abbreviation, as shown below:
When withdrawing assets from a multi-signed address, multiple signatures are required. A json string is returned requiring signatures, as shown below:
sign
This command is used to sign when withdrawing assets from a multi-signed address which requires multiple signatures.The translation can be broadcasted only after signing is completed.
Syntax
sign <jsonObjectToSign>
Parameters
jsonObjectToSign
:The json string that records the transaction information.
Example
relay
After signing completed, this command can be used to broadcast the transaction information.
Syntax
relay <jsonObjectToSign>
Parameters
jsonObjectToSign
:The json string that records the transaction information.
Example
install
Installs plugins.
install [Plugin name]
To install a plugin, enter the command as follows:
For information about all plugins refer to Install Plug-ins .
export block[s]
Exports the whole blockchain data or export the specified amount of block data from the specified block height. The output can be used for offline synchronization. Before you can use this command you need to install the plugin ImportBlocks.
Syntax
export block[s] [path=chain.acc]
export block[s] <start> [count]
Parameters
[path=chain.acc]
:Export the whole blockchain data.
<start> [count]
:The height of the starting block and the number of blocks to export data.
dump storage <key>
start consensus
Start the consensus on the premise that the wallet has a consensus authority, allows consensus authority to be obtained on the main net through voting. If a private chain is deployed, public key of the consensus can be set up in the protocol.json
. For more information refer to Setting up Private Chain .