Skip to main content

=nil; CLI

The =nil; CLI offers a convenient way for interacting with the cluster by abstracting over JSON-RPC methods.

The CLI can also be integrated into a CI/CD pipeline. For example, a pipeline may retrieve certain values from a contract and then use the received data in subsequent commands.

This page lists all commands exposed by the =nil; CLI as well as their flags and arguments.

Global flags

The following flags can be used with any command.

FlagDefinition
--quiet | -qEnable quiet mode (the CLI will only output values with no additional text).
--verbose | -vEnable verbose mode (the CLI will attach additional explanatory text to every output).
--help | -hReceive help for the command.

The following flags can be used without a command.

FlagDefinition
--config | -cSpecify the path to the =nil; CLI config file.
--log-level | -lSet the =nil; CLI logging level. Possible values: trace, debug, info, warn, error, fatal, panic.

block

Description

This command allows for reading block information.

Subcommands

No subcommands.

Flags

FlagDefinition
--shard-id ShardIdSpecify the id of the shard from which the block should be retrieved.

Examples

Retrieve a block by hash

nil_cli block BLOCK_HASH [--shard-id SHARD_ID; default 1]

Retrieve a block by number

nil_cli block BLOCK_NUMBER [--shard-id SHARD_ID; default 1]

Retrieve the latest block

nil_cli block latest [--shard-id SHARD_ID; default 1]

Output

Fetched block:
{
"hash": "{BLOCK_HASH}",
"inMessagesRoot": "{IN_MESSAGE_ROOT}",
"messages": [MESSAGES],
"number": {BLOCK_NUMBER},
"parentHash": "{PARENT_HASH}",
"receiptsRoot": "{RECEIPTS_ROOT}",
"shardId": {BLOCK_HASH}
}

completion

Description

This command generates autocompletion scripts for various shells.

Subcommands

SubcommandDefinition
bashGenerate the autocompletion script for bash.
fishGenerate the autocompletion script for fish.
powershellGenerate the autocompletion script for powershell.
zshGenerate the autocompletion script for zsh.

Example

nil_cli completion bash | fish | powershell | zsh

Output

COMPLETION_SCRIPT

config

Description

This command is for setting up the =nil; CLI.

Subcommands

Subcommands

SubcommandDefinition
getGets the value of the provided config key.
setSets the given value to the provided config key.
initInitializes the =nil; CLI config file.
showShows the current contents of the =nil; CLI config file.

Examples

Initialize the config file

nil_cli config init

Set a config value

nil_cli config set KEY VALUE

Read a config value

nil_cli config get KEY

Show the contents of the config file

nil_cli config show

Outputs

Initializing the config file

Config initialized successfully: config.yaml

Setting a config value

Set "KEY" to "VALUE"

Getting a config value

KEY: Value

Showing the contents of the file

Config file: config.yaml
KEY: VALUE
...

contract

Description

This command is for reading contract information and for interacting with smart contracts via external messages.

Subcommands

SubcommandDefinition
addressCalculate the smart contract address given its bytecode.
balanceRetrieve the balance of the smart contract.
call-readonlyCall a smart contract method via an external message.
codeRetrieves the smart contract bytecode.
currenciesRetrieves the currencies mapping of the smart contract.
deployDeploys the smart contract.

Flags

For address:

FlagDefinition
--abi stringThe path to the .abi file containing the contract ABI.
--salt Uint256Arbitrary salt.
--shard-id ShardIdThe ID of the shard where the contract is located/could be located.

For call-readonly:

FlagDefinition
--abi stringThe path to the .abi file containing the contract ABI.
--gas-limit Uint256The gas limit for the call.

For deploy:

FlagDefinition
--abi stringThe path to the .abi file containing the contract ABI.
--no-waitPrevents waiting for the deployment message receipt when the command is executing.
--salt Uint256Arbitrary salt.
--shard-id ShardIdThe ID of the shard where the contract is located/could be located.

Examples

Calculate the smart contract address

nil_cli contract address path/to/contract.bin [--abi path/to/contract.abi] [--no-wait] [--salt SALT] [--shard-id SHARD_ID; default 1]

Call a smart contract method

nil_cli contract call-readonly CONTRACT_ADDRESS CALLDATA | METHOD_NAME [--abi path/to/contract.abi] [--gas-limit GAS_LIMIT]

Deploy a smart contract

nil_cli contract deploy path/to/contract.bin [--abi path/to/contract.abi] [--no-wait] [--salt SALT] [--shard-id SHARD_ID; default 1]

Retrieve the code of a smart contract

nil_cli contract code CONTRACT_ADDRESS

Retrieve the balance of a smart contract

nil_cli contract balance CONTRACT_ADDRESS

Retrieve the currencies of a smart contract

nil_cli contract currencies CONTRACT_ADDRESS

Outputs

Calculating the smart contract address

Contract address: CONTRACT_ADDRESS

Calling a smart contract method

Call results: CALL_RESULTS

Deploying a contract

Contract address: CONTRACT_ADDRESS

Retrieving the code of a smart contract

Contrace code: CONTRACT_CODE

Retrieving the contract balance

Contract balance: CONTRACT_BALANCE

Retrievign the contract currencies

Contract currencies: CONTRACT_CURRENCIES

help

This command is for receiving help for the =nil; CLI.

Subcommands

No subcommands.

Flags

No flags.

Example

nil_cli help

Output

CLI tool for interacting with the =nil; cluster

Usage:
nil_cli [command]

Available Commands:
block Retrieve a block from the cluster
completion Generate the autocompletion script for the specified shell
config Configuration management
contract Interact with contract on the cluster
help Help about any command
keygen Generate a new key or generate a key from a provided hex private key
message Retrieve a message from the cluster
minter Interact with minter on the cluster
receipt Retrieve a receipt from the cluster
system Request system-wide information
wallet Interact with wallet on the cluster

Flags:
-c, --config string Path to config file (default "config.yaml")
-h, --help help for nil_cli
-l, --log-level string Log level: trace|debug|info|warn|error|fatal|panic (default "trace")
-q, --quiet Quiet mode (print only the result and exit)
-v, --verbose Verbose mode (print logs)

keygen

This command is for generating private keys.

Subcommands

SubcommandDefinition
fromHex stringGenerate a new key from the provided hex of a private key.
newGenerate a new key.

Examples

Generate a new key from hex

nil_cli keygen fromHex HEX

Generating a new key

nil_cli keygen new

Output

Private key: PRIVATE_KEY

message

This command is for retrieving a message from the cluster.

Subcommands

No subcommands.

Flags

FlagDefinition
--shard-id ShardIdSpecify the id of the shard from which the message should be retrieved.

Example

nil_cli message MESSAGE_HASH [--shard-id SHARD_ID; default 1]

Output

Fetched message:
{
"blockHash": "{BLOCK_HASH}",
"blockNumber": BLOCK_NUMBER,
"chainId": "{CHAIN_ID}",
"from": "{ADDRESS_FROM}",
"gasLimit": "{GAS_LIMIT}",
"gasPrice": "{GAS_PRICE}",
"gasUsed": "{GAS_USED}",
"hash": "{MESSAGE_HASH}",
"index": "{INDEX}",
"seqno": "{SEQUENCE_NUMBER}",
"signature": "{SIGNATURE}",
"success": SUCCESS,
"to": "{ADDRESS_TO}",
"value": "{VALUE}"
"data": "DATA"
}

minter

This command is for interacting with the =nil; currency minter.

Subcommands

SubcommandDefinition
create-currencyCreate a new currency and, optionally, withdraw it.
mint-currencyMint an existing currency and, optionally, withdraw it.
withdraw-currencyWithdraw an existing currency that has been minted.

Flags

For create-currency, mint-currency:

FlagDefinition
--withdrawImmediately withdraw the created/minted currency to its owner.

Examples

Create a new token

nil_cli minter create-currency OWNER_ADDRESS AMOUNT NAME [--withdraw]

Mint an existign token

nil_cli minter mint-currency OWNER_ADDRESS AMOUNT [--withdraw]

Withdraw tokens

nil_cli minter withdraw-currency OWNER_ADDRESS AMOUNT TO_ADDRESS

Outputs

Creating a new token

Created NAME:AMOUNT CurrencyId=[CURRENCY_ID]

Minting a new token

Minted AMOUNT CurrencyId=[CURRENCY_ID]

Withdrawing tokens

Transferred AMOUNT to TO_ADDRESS CurrencyId=[CURRENCY_ID]

receipt

This command is for retriving the receipt with the given hash.

Subcommands

No subcommands.

Flags

FlagDefinition
--shard-id ShardIdSpecify the id of the shard from which the receipt must be retrieved.

Example

nil_cli receipt MESSAGE_HASH [--shard-id SHARD_ID; default 1]

Output

Fetched receipt:
{
"blockHash": "{BLOCK_HASH}",
"blockNumber": BLOCK_NUMBER,
"bloom": "{BLOOM}",
"contractAddress": "{CONTRACT_ADDRESS}",
"gasUsed": GAS_USED,
"logs": [],
"messageHash": "{MESSAGE_HASH}",
"messageIndex": INDEX,
"outMsgIndex": OUT_MESSAGE_INDEX,
"success": SUCCESS
}

system

This command is for retrieving system information.

Subcommands

SubcommandDefinition
chain-idRetreive the ID of the current chain.
gas-priceRetrieve the gas price in the specified shard.
shardsRetrieve a list of all execution shards.

Examples

Retrieve the ID of the current chain

nil_cli system chain-id

Retrieve the gas price at the specified shard

nil_cli system gas-price shard-id SHARD_ID

Retrieve the list of all execution shards

nil_cli system shards

Output

Retrieving the ID of the current chain

ChainId: CHAIN_ID

Retrieving the gas price at the specified shard

Gas price of shard SHARD_ID: GAS_PRICE

Retrieving the list of all execution shards

List of shard id:
* SHARD_ID
* SHARD_ID
...

wallet

This command is for interacting with wallets.

Subcommands

SubcommandDefinition
balanceRetrieves the balance of the wallet specified in the =nil; CLI config.
deployDeploys a smart contract via the wallet.
infoRetrives the wallet's address and the public key.
newCreate a new wallet.
send-messageSend a message to a deployed smart contract via the wallet.
send-tokensSend tokens to the wallet.
top-upRequest a 'top up' from the faucet.

Flags

For deploy:

FlagDefinition
--abi stringSpecify the path to the .abi file for the contract.
--amount Uint256Set the amount of tokens to send to the contract.
--currency Uint256Set the amount of contract currency to generate (cannot be used with the --no-wait flag).
--no-waitDefine whether the command should wait for the message receipt.
--salt Uint256Set the salt for the deployment message.
--shard-id ShardIdSpecify the shard where the contract should be deployed.

For new:

FlagDefinition
--amount Uint256Set the initial balance of the wallet (capped at 10 000 000)
--salt Uint256Set the salt for the deployment message.
--shard-id ShardIdSpecify the shard where the wallet should be deployed.

For send-message:

FlagDefinition
--abi stringSpecify the path to the .abi file for the contract.
--amount Uint256Set the amount of tokens to send to the contract.
--gas-limit Uint256Set the message gas limit.
--no-waitDefine whether the command should wait for the message receipt.
--token stringArrayDefine the tokens to transfer to the contract. Tokens are set using the CURRENCY_ID=AMOUNT format. The flag accepts can accept multiple tokens.

For send-tokens:

FlagDefinition
--gas-limit Uint256Set the message gas limit.
--no-waitDefine whether the command should wait for the message receipt.
--token stringArrayDefine the tokens to transfer to the contract. Tokens are set using the CURRENCY_ID=AMOUNT format. The flag accepts can accept multiple tokens.

Examples

View the wallet balance

nil_cli wallet balance

Deploy a smart contract

nil_cli wallet deploy path/to/contract.bin [ARGS] [--abi path/to/contract.abi] [--amount AMOUNT] [--currency TOKENS_AMOUNT] [--no-wait] [--salt SALT] [shard-id SHARD_ID] 

Send tokens to a smart contract

nil_cli send-tokens ADDRESS [--gas-limit GAS_LIMIT] [--no-wait] [--token stringArray]

Request a 'top up'

nil_cli wallet top-up AMOUNT

Retrieve wallet information

nil_cli wallet info

Create a new wallet

nil_cli wallet new [--amount AMOUNT] [--salt SALT] [--shard-id SHARD_ID]

Send a message to a smart contract

nil_cli wallet send-message ADDRESS BYTECODE | METHOD [ARGS] [--abi path/to/contract.abi] [--amount AMOUNT] [--gas-limit GAS_LIMIT] [--no-wait] [--token TOKENS] 

Outputs

Viewing the wallet balance

Contract balance: BALANCE

Deploying a smart contract

Contract address: ADDRESS
Transaction hash: TRANSACTION_HASH

Creating a new wallet

Contract ADDRESS balance is topped up by AMOUNT
Contract address: ADDRESS
Transaction hash: TRANSACTION_HASH
New wallet address: ADDRESS

Sending a message to a smart contract

Transaction hash: TRANSACTION_HASH

Retrieving wallet information

Address: ADDRESS
Public key: PUBKEY

Requesting a 'top up'

Contract ADDRESS balance is topped up by AMOUNT
Contract balance: BALANCE

Sending tokens to a smart contract

Transaction hash: TRANSACTION_HASH