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 CLI.

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.
--help | -hReceive help for the command.

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 block BLOCK_HASH [--shard-id SHARD_ID; default 1]

Retrieve a block by number

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

Retrieve the latest block

nil 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 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 config init

Set a config value

nil config set KEY VALUE

Read a config value

nil config get KEY

Show the contents of the config file

nil 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.
estimate-feeEstimates the gas needed to execute the given message.

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.
--fee-credit Uint256The fee credit 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.

For estimate-fee:

FlagDefinition
--abi stringSpecify the path to the .abi file for the contract.
--value Uint256Set the amount of tokens to send to the contract.
--deployDefine whether the message should be treated as a deployment message.
--internalDefine whether the gas should be estimated for an internal message.

Examples

Calculate the smart contract address

nil 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 contract call-readonly CONTRACT_ADDRESS CALLDATA | METHOD_NAME [--abi path/to/contract.abi] [--fee-credit FEE_CREDIT]

Deploy a smart contract

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

Estimate a fee

nil contract estimate-fee ADDRESS FUNC_NAME [ARGS] [--abi path/to/contract.abi] [--deploy] [--internal] [--value AMOUNT]

Retrieve the code of a smart contract

nil contract code CONTRACT_ADDRESS

Retrieve the balance of a smart contract

nil contract balance CONTRACT_ADDRESS

Retrieve the currencies of a smart contract

nil 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 help

Output

CLI tool for interacting with the =nil; cluster

Usage:
nil [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
-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 keygen fromHex HEX

Generating a new key

nil 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 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 minter create-currency OWNER_ADDRESS AMOUNT NAME [--withdraw]

Mint an existign token

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

Withdraw tokens

nil 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 retrieving 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 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 system chain-id

Retrieve the gas price at the specified shard

nil system gas-price shard-id SHARD_ID

Retrieve the list of all execution shards

nil 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.
call-readonlyPerforms a read-only 'dry run' call to the specified address.
deployDeploys a smart contract via the wallet.
estimate-feeEstimates the fee for sending the specified message.
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 call-readonly:

FlagDefinition
--abi stringSpecify the path to the .abi file for the contract.
--fee-credit Uint256Set the call fee credit.
--in-overrides stringSet the input state overrides.
--out-overrides stringSet the output state overrides.
--with-detailsDefine whether the output should show the tokens used and outbound messages.

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 estimate-fee

FlagDefinition
--abi stringSpecify the path to the .abi file for the contract.
--value Uint256Set the amount of tokens to send to the contract.
--deployDefine whether the message should be treated as a deployment message.

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.
--fee-credit Uint256Set the message fee credit.
--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
--fee-credit Uint256Set the message fee credit.
--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 wallet balance

Perform a read-only call

nil wallet call-readonly ADDRESS [--abi path/to/contract.abi] [--fee-credit FEE_CREDIT] [--in-overrides IN_OVERRIDES] [--out-overrides OUT_OVERRIDES] [--with-details]

Deploy a smart contract

nil 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]

Estimate a message fee

nil wallet estimate-fee ADDRESS FUNC_NAME [ARGS] [--abi path/to/contract.abi] [--deploy] [--value AMOUNT]

Send tokens to a smart contract

nil send-tokens ADDRESS [--fee-credit FEE_CREDIT] [--no-wait] [--token stringArray]

Request a 'top up'

nil wallet top-up AMOUNT

Retrieve wallet information

nil wallet info

Create a new wallet

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

Send a message to a smart contract

nil wallet send-message ADDRESS BYTECODE | METHOD [ARGS] [--abi path/to/contract.abi] [--amount AMOUNT] [--fee-credit FEE_CREDIT] [--no-wait] [--token TOKENS]

Outputs

Viewing the wallet balance

Contract balance: BALANCE

Performing a read-only call

STATUS, result:
TYPE: VALUE

Deploying a smart contract

Contract address: ADDRESS
Transaction hash: TRANSACTION_HASH

Estimating a message fee

Estimated external message fee: AMOUNT
Estimated internal message fee: AMOUNT

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