โŒจ๏ธCLI Reference

The cli subcommand provides a human-friendly command-line interface to the node JSON-RPC API.

Usage

See all the available options by running the help command using docker, binary or cargo.

docker exec witnet_node witnet node --help

To get more information about any specific command, simply add --help at the end. For instance, this will show the available options for the blockchain command:

docker exec witnet_node witnet node blockchain --help

The JSON-RPC server address is obtained from the Configuration file. The path of this file can be set using the -c or --config flag. This flag must appear before node.

docker exec witnet_node witnet node -c witnet.toml node blockchain

You can use the -n flag to easily overwrite the node address. This flag must appear after the command name.

docker exec witnet_node witnet node -c witnet.toml node blockchain -n "127.0.0.1:1234"

If there is any error, the process will return a non-zero exit code.

    docker exec witnet_node witnet node node blockchain
    Error: Connection refused (os error 111)

The executable implements the usual logging API, which can be enabled using RUST_LOG=witnet=debug:

    $ docker exec witnet_node witnet node blockchain
    INFO 2019-01-03T12:04:43Z: witnet::json_rpc_client: Connecting to JSON-RPC server at 127.0.0.1:21338
    ERROR 2019-01-03T12:04:43Z: witnet: Error: Connection refused (os error 111)

Commands

addPeers

Add addresses to the node's peers and try to connect to them.

The IP addresses are expected in format: list of "address:port" separated by spaces.

Example output:

address

Get the identifier of the node that acts as its address when interacting with the protocol through transactions.

This is the address used for mining blocks, resolving data requests, and receiving value transfer transactions.

Example output:

authorizeStake

Create an stake authorization.

  • --node=socket: Socket address of the Witnet node to query.

  • --withdrawer=address: Withdrawer address. Uses node's pkh if withdrawer is not specified.

Example output:

balance

Get total balance of a given Witnet address. Balances are shown in wits.

  • --address=address: address for which to get balance. If omitted, defaults to the node's own address.

Example output:

block

Print out detailed information about a block being queried by its hash.

The hash of the block should be provided as a hexadecimal string.

Example output:

blockchain

List block hashes in the local block chain, matched with their epochs.

This method accepts two optional arguments:

  • --epoch=n: the first epoch for which to show block hashes. A negative epoch means "n epochs ago".

  • --limit=n: the number of epochs. If zero, unlimited.

Example output:

config

Show the loaded configuration in Toml format to stdout.

dataRequestReport

Show information about a data request.

Example output:

If you want to see the request move forwards through its different stages in real time you can use the watch command while it is being resolved:

joinTransaction

Create a value transfer transaction that joins UTXOs.

The following arguments must be provided.

  • --value=amount: amount in nanoWits.

  • --fee=fee: miner fee in nanoWits.

knownPeers

Get the list of peer addresses known to the node. These addresses are tagged as:

masterKeyExport

Export the node's master private key. Please keep this totally secret. Anyone with knowledge of this key has full access to all your wit tokens.

minerList

Display the list of block hashes for each epoch, their miners and the numbers of blocks mined by each address.

nodeStats

Display local node stats.

Among other information, this shows counters for proposed and accepted blocks and participations in resolving data requests ("commitments"):

Block mining stats

  • Proposed blocks

  • Blocks included in the block chain

Data Request mining stats:

  • Times with eligibility to mine a data request

  • Proposed commits

  • Accepted commits

  • Slashed commits

Example output:

!!! tip Note that it is perfectly normal for a node to show 0 "blocks included" or "accepted commits" for the first days of it being up. Please be patient, new identities in the system are subject to a slow start for critical security reasons.

output

Display a transaction output, as referred by it's "output pointer", that is, <transaction_id>:<output_index>.

peers

List inbound and outbound connections currently established by the node. Outbound connections are those initiated on our side, and inbound connections are those that were initiated by peer nodes. A node that does not announce a public address (IP and port) will normally have no inbound connections, as there is no way for other nodes to discover a valid network route to it.

priority

Display priority and time-to-block estimations for different priority tiers according to the current state of the network. The priority is measured in nanowits per weight unit, so you can calculate a fee by multiplying the priority by the weight of the transaction.

Example output:

raw

The raw command allows sending raw JSON-RPC requests from the command line. It can be used in an interactive way (don't forget the -i flag when using Docker): each line of user input will be sent to the JSON-RPC server without any modifications:

Each block represents a method call: the first line is a request, the second line is a response.

Alternatively, the input can be read from a file using pipes, as is usual in Unix-like environments. For instance, the bitcoin_price.json data request example from the witnet-rust reposity can be easily deployed into the network using the raw command like this:

reputation

Displays the reputation score associated with a given Witnet address and its elegibility to mine a block.

  • --address=address: address for which to get reputation score. If omitted, defaults to the node's own address.

Example output:

The parameter [A] notifies that the node is active.

Adding the flag --all lists all the nodes active and their elegibility. It also lists the nodes with reputation grater than 0 but not active, if any.

!!! tip Note that it is perfectly normal for a node to show 0 reputation for the first days of it being up. Please be patient, new identities in the system are subject to a slow start for critical security reasons.

Example output:

send

Create and broadcast a value transfer transaction. That is, send some amount of wit tokens from the node's own balance into a different Witnet address.

  • --address=address: recipient address.

  • --value=amount: amount in nanoWits.

  • --fee=fee: miner fee in nanoWits.

  • --time-lock=timestamp: optional time lock for the created output: the receiver will not be able to spend the output until the timestamp is reached. 0 means no time-lock.

On success, returns the transaction hash:

On error, returns the error message:

Example with time lock set to 2019-10-01

sendRequest

Send a serialized data request. An example of how to create such a request can be found in the tutorial.

server

Run a Witnet node server.

snapshot-export

Export the current chain state.

  • path: The path to store the exported chain state.

  • --force: Flag that bypasses checks, and allows to export when not fully synced.

snapshot-import

Start node and sync to a known chain state.

  • path: The path to .bin file from an exported chain state.

  • --force: Flag that bypasses checks.

splitTransaction

Create a value transfer transaction that splits UTXOs.

The following arguments must be provided:

  • --value=amount: amount in nanoWits.

  • --size=size: amount in nanoWits of each UTXO.

  • --fee=fee: miner fee in nanoWits.

stake

Create a stake transaction.

  • --authorization=authorization: Stake authorization code (the withdrawer address, signed by the validator node)

  • --fee=fee: miner fee in nanoWits.

  • --node=node: Socket address of the Witnet node to query

  • --require_confirmation=true: If unset or set to true, the command is interactive and prompts for user confirmation. If set to false, skip confirmation and complete the command without user confirmation.

  • --value=value : Value to stake in nanoWits. Minimum stake amount is 10000 $WIT and maximum is 10000000 $WIT.

  • --withdrawer=address: Withdrawer address.

  • --dry-run=true: Print the request that would be sent to the node and exit without doing anything.

transaction

Print out detailed information about a transaction being queried by its hash.

The hash of the transaction should be provided as a hexadecimal string.

Example output:

unstake

Create an unstake transaction.

  • --node=node: Socket address of the Witnet node to query.

  • --operator=address: Node address operating the staked coins.

  • --fee=fee: miner fee in nanoWits.

  • --value=value : Value to unstake in nanoWits. Minimum stake amount is 10000 $WIT.

  • --dry-run=true: Print the request that would be sent to the node and exit without doing anything.

utxos

Get the unspent transaction outputs of the node. This shows how many UTXOs are available for your node to spend or collateralize.

The output includes information about:

  • Total number of utxos

  • Total number of utxos bigger than collateral minimum

  • Total number of utxos older than collateral coinage

The flag --long can be added to the command to get a detailed list of the UTXOs and whether each of them is spendable or collateralizable at this time.

Last updated

Was this helpful?