Open the command line, navigate to the directory where Neo-CLI is located, and enter the following code to start the command line Neo node.
dotnet neo-cli.dll
This section will introduce all the commands in the command line node. You can manipulate your node 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 Neo-CLI version
help [plugin-name]
Help menu, which can also show plugin related commands.
Converts the input string into various supported data formats.
Syntax
parse <value>
Example
If you see messy codes that is because some data types cannot be converted. You can also use https://neo.org/converter to convert.
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.
delete address
Delete an address from wallet.
Syntax
delete address <address>
Example
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
change password
Changes the wallet password.
Syntax
change password
Example
upgrade wallet
Upgrades the old .db3 wallet file into the .json format.
Syntax
upgrade wallet <path>
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 Neo N3, The GAS in an account is claimed automatically every time when the number of Neo in the account changes.
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
balanceof
Queries the balance of specified token at the specified address
Syntax
balanceof <tokenHash> <address>
Parameters
tokenHash : The token hash
address : The address to query
Example
decimals
Queries the precision of specified token
Syntax
decimals <tokenHash>
Parameters
tokenHash : The token hash
Example
name
Queries the name of specified token
Syntax
name <tokenHash>
Parameters
tokenHash : The token hash
Example
totalsupply
Queries the total supply of specified token
Syntax
totalsupply <tokenHash>
Parameters
tokenHash : The token hash
Example
transfer
Invokes the transfer method to transfer the specified token.
Syntax
transfer <tokenHash> <to> <amount> [from=null] [data=null] [signersAccounts=null]
Parameters
tokenHash : The token hash
to : The address you transfer the token to
amount : The amount to transfer
from : The address you transfer the token from
data :The additional parameter. The default value is null.
signersAccounts : The signer's address
Example
list nativecontract
Lists all the native contract names and scripthash.
Syntax
list nativecontract
Example
get accountstate
Gets the latest voting information of the specific account, including the address it voted, the amount of votes cast and the block height at the time of voting.
Syntax
get accountstate <address>
Parameter
address :The address you want to query the voting information.
Example
get candidates
Gets candidates' public keys and votes
Syntax
get candidates
Example
get committee
Gets the committee member's public key
Syntax
get committee
Example
get next validators
Gets the next validator's public key
Syntax
get next validators
Example
register candidate
Registers the candidate
Syntax
register candidate <account> [maxGas=1010]
Parameters
account : The account to register candidate
maxGas : The maximum GAS can be consumed. Default is 1010, where the registration fee is 1000 GAS.
Example
unregister candidate
Unregisters the candidate
Syntax
unregister candidate <account>
Parameters
account : The account to unregister candidate
Example
vote
Votes for candidates
Syntax
vote <senderAccount> <publicKey>
Parameters
senderAccount : The account used to vote
publickey : The public key of the account you vote for
Example
unvote
Cancel the voting
Syntax
unvote <senderAccount>
Parameter
senderAccount : The account to unvote
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 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
import watchonly
Imports the watch-only address, e.g contract account.
Syntax
import watchonly scriptHash
Parameters
addressOrFile :account address, hash, contract hash, or files storing these data
Example
send
Transfers the asset to the specified address. The command requires the verification of the wallet password.
id | alias : asset ID or asset abbreviations, e.g. neo, gas
address : address to transfer assets to
amount : transfer amount
from : address to transfer assets from
data : the additional transaction information, which defaults to null.
signerAccounts : signer's address
Example
Transfer 100 Neo to the address Ni5iS2XHazKZtXfzLJbdyDk8UUcGBZGePR:
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:
When withdrawing assets from a contract, from is the contract hash and the signer account must contain the contract hash and verify account, for example:
sign
This command is used to sign ContractParametersContext. The translation can be broadcasted only after signing is completed.
Syntax
sign <jsonObjectToSign>
Parameters
jsonObjectToSign : The json string that records the transaction information.
Example
The signed json string is returned. If the signature is complete, you can broadcast the transaction using the command relay .
cancel
Cancel unconfirmed transactions (in memory pool). Only transactions in the memory pool can be canceled, e.g. if you send two identical transactions, you can cancel one of them in a short time (before the consensus node confirms it).
Syntax
cancel <txid> [sender=null] [signerAccounts=null]
Example
deploy
Deploys a contract on the blockchain.
Syntax
deploy <nefFilePath> [manifestFile]
Parameters
nefFilePath : Path to the executable file (.nef) of NeoVM.
manifestFile : Path to the file manifest.json, which records each interface information and configuration content of the contract.
command : Method name in the contract, which can be followed by input parameters separated by space.
contractParameters : Parameters to invoke. You need to pass in JSON-formatted string. For ByteArray type, encode it with Base64 in advance.
For example, the address NfKA6zAixybBHHpmaPYPDywoqDaKzfMPf9 can be converted to the hexadecimal big-endian script hash 0xe4b0b6fa65a399d7233827502b178ece1912cdd4 or the Base64-encoded script hash 1M0SGc6OFytQJzgj15mjZfq2sOQ= . The JSON-formatted parameters are:
sender : Transaction sender, i.e. the GAS payment account.
signerAccounts : An array of co-signed addresses and only supports standard accounts (single address). After filling in Neo-CLI will append signatures of all addresses in the array to the invocation transaction.
maxGas : The maximum GAS can be consumed.
Example 1
Input:
Output:
VM State : there are two states:
HALT : the virtual machine executes successfully.
FAULT : the virtual machine exits during execution due to an exception.
Gas Consumed : the system fees consumed for smart contract invocation.
Evaluation Stack : shows the result of contract execution, where the value is encoded with Base64.
Input:
Output:
Output:
or
Output:
Example 3
Input:
Output:
After entering the invoke command, the node invokes the operation method, and passes operation and contractParameters as arguments. If operation and contractParameters are not processed in the contract, the expected result will not be returned.
nefFilePath : File path to the NeoVM executable file nef.
manifestFile : Path of the manifest.json file which records all the contract interfaces and configuration. If not specified, the manifest.json with the same name as nef will be automatically matched.
sender : The transaction sender that pays for GAS
signerAccounts : An array of co-signed addresses and only supports standard accounts (single address). After filling in Neo-CLI will append signatures of all addresses in the array to the invocation transaction.
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
broadcast addr
Broadcasts the IP address of a block.
Syntax
broadcast addr <IPAddress> <port>
Example
broadcast block
Broadcasts a block.
Syntax
broadcast block <block-hash>
broadcast block <block-height>
Example
broadcast getblocks
Broadcasts the getblocks request.
Syntax
broadcast getblocks <block-hash>
Example
broadcast getheaders
Broadcasts the getheaders request.
Syntax
broadcast getheaders <block-hash>
Example
broadcast getdata
Broadcasts the getdata request.
Syntax
broadcast getdata <inventory type> <payload>
Example
broadcast inv
Broadcasts inventory data.
Syntax
broadcast inv <inventory type> <payload>
Example
broadcast transaction
Broadcasts a transaction.
Syntax
broadcast transaction <transaction hash>
Example
plugins
Shows all the loaded plugins.
Syntax
plugins
Example
install
Installs plugins.
install [Plugin name]
To install a plugin, enter the command as follows:
Exports the block data from the specified block height. The output can be used for offline synchronization.
Syntax
export blocks <index>
Parameters
<index> : The height of the starting block from which the data is exported.
show blocks
Output block details via block height or block hash.
Syntax
show block <indexOrHash>
Parameters
<indexOrHash> : The index or height of the block.
Example
show contract
Output contract details by contract name or contract hash.
Syntax
show contract <nameOrHash>
Parameters
<nameOrHash> : The name or hash of the contract.
Example
show tx
Output transaction details via transaction hash.
Syntax
show tx <hash>
Parameters
<hash> : The transaction hash of transaction.
Example
start consensus
Starts the consensus on the premise that the wallet has a consensus authority, allows consensus authority to be obtained on the main net through voting. This command requires installation of the DBFTPlugin. 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 .
start oracle
Starts Oracle. This command requires installation of the OracleService plugin. The Oracle service is enabled only if the public key of the current wallet address has been assigned the Oracle role by the committee.
stop oracle
Stops Oracle. This command requires installation of the OracleService plugin.
state root
Queries the state root with index. This command requires installation of the StateService plugin.
Syntax
state root <index>
Parameters
<index> : The block index
get proof
Gets proof with root hash, contract hash, and storage key.
Syntax
get proof <root hash> <script hash> <key>
Parameters
<root hash> : hash of the state root.
<script hash> : Contract hash
<key> : key of the storage; Base64-encoded.
verify proof
Verifies with root hash and proof.
Syntax
verify proof <root hash> <proof>
Parameters
<root hash> : hash of the state root.
<proof> : proof of the state root; Base64-encoded.