Command-Line-Interface

General commands

Help

Displays command reference.

A command line interface for Klayr

VERSION
  klayr-commander/5.1.10 darwin-x64 node-v18.16.0

USAGE
  $ klayr [COMMAND]

TOPICS
  account     Commands relating to Klayr accounts.
  generate    Commands relating to Klayr generator.
  message     Commands relating to user messages.
  passphrase  Commands relating to Klayr passphrases.

COMMANDS
  autocomplete        Display autocomplete installation instructions.
  console             Klayr interactive REPL (Read-eval-print loop), session to run commands.
  hash-onion          Create hash onions to be used by the forger.
  help                Display help for klayr.
  init                Bootstrap a blockchain client using Klayr SDK.
  network-identifier  Creates Network identifier for the given genesis block id and community identifier.

Init

Bootstrap a blockchain client using the Klayr SDK.

USAGE
  $ klayr init [PROJECTPATH]

ARGUMENTS
  PROJECTPATH  [default: process.cwd] Path to create the project.

OPTIONS
  -t, --template=template  Template to bootstrap the application. It will read from `.klayrrc.json` or use `klayr-ts` if not found.
  --registry=registry      URL of a registry to download dependencies from.

EXAMPLES
  init
  init --template klayr-ts
  init --template @some-global-npm-package
  init /project/path
  init /project/path --template klayr-ts

Console

Klayr interactive REPL session to run commands.

USAGE
  $ klayr console

OPTIONS
  --api-ipc=api-ipc  Enable api-client with IPC communication.
  --api-ws=api-ws    Enable api-client with Websocket communication.

EXAMPLES
  console
  console --api-ws=ws://localhost:8080
  console --api-ipc=/path/to/server

Hash onion

Creates a hash onion output to be used by a forger.

Create hash onions to be used by the forger.

USAGE
  $ klayr hash-onion

OPTIONS
  -c, --count=count        [default: 1000000] Total number of hashes to produce.
  -d, --distance=distance  [default: 1000] Distance between each hashes.
  -o, --output=output      Output file path.
  --pretty                 Prints JSON in pretty format rather than condensed.

EXAMPLES
  hash-onion --count=1000000 --distance=2000 --pretty
  hash-onion --count=1000000 --distance=2000 --output ~/my_onion.json

Network identifier

Displays the Network identifier based on the payload hash of the genesis block of the network. The Network identifier needs to be provided everytime a transaction is signed, which ensures that the transaction can only be broadcasted in the dedicated network.

USAGE
  $ klayr network-identifier GENESISBLOCKID

ARGUMENTS
  GENESISBLOCKID  ID of genesis block from the network.

OPTIONS
  -j, --[no-]json                              Prints output in JSON format. You can change the default behavior in your
                                               config.json file.

  --community-identifier=community-identifier  [default: Klayr] Unique community identifier for network.

  --[no-]pretty                                Prints JSON in pretty format rather than condensed. Has no effect if the output is
                                               set to table. You can change the default behavior in your config.json file.

DESCRIPTION
  Creates Network identifier for the given genesis block id and community identifier.

EXAMPLE
  network-identifier da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba

Example JSON output

{ "networkIdentifier":"10f236f6d00a8f565bbe43c4ef0e3818f488bf4abefbe041155a3d019ef9a947" }

Autocomplete

Display instructions how to enable auto-completion for Klayr Commander commmands.

USAGE
  $ klayr autocomplete [SHELL]

ARGUMENTS
  SHELL  shell type

OPTIONS
  -r, --refresh-cache  Refresh cache (ignores displaying instructions)

EXAMPLES
  $ klayr autocomplete
  $ klayr autocomplete bash
  $ klayr autocomplete zsh
  $ klayr autocomplete --refresh-cache

Account

Commands relating to Klayr accounts.

USAGE
  $ klayr account:COMMAND

COMMANDS
  account:create  Return randomly-generated mnemonic passphrase with its corresponding public/private key pair and Klayr address.
  account:show    Show account information for a given passphrase.

Create account

This returns a randomly-generated mnemonic passphrase with its corresponding public/private key pair and Klayr address.

USAGE
  $ klayr account:create

OPTIONS
  -c, --count=count  [default: 1] Number of accounts to create.

EXAMPLES
  account:create
  account:create --count=3

Example output

[
 {
  "passphrase": "panda abuse stamp hungry sad hour tent mesh narrow whale napkin file",
  "privateKey": "a00c8107d40a8a678b5e9f4533bd4e740c446a1967300139b16fd62b0184cad51dc86a88278ee6db12ff671318677ec23b9ee6231cfca71a2c99c2ab78338cb1",
  "publicKey": "1dc86a88278ee6db12ff671318677ec23b9ee6231cfca71a2c99c2ab78338cb1",
  "binaryAddress": "3e565c6f2d22e0a3c1e4717672ec8ac61c2660f2",
  "address": "klyna5m2sa9p5u6nu8p7msnmsp6227vo2nrzvczsq"
 }
]

Show account

Shows account information for a given passphrase. It displays the Klayr address, the address as hexadecimal string, the publickey and the privatekey that belong to the entered passphrase:

USAGE
  $ klayr account:show

OPTIONS
  -p, --passphrase=passphrase  Specifies a source for your secret passphrase.
                                Command will prompt you for input if this option is not set.
                               	Examples:
                               	- --passphrase='my secret passphrase' (should only be used where security is not important)

EXAMPLE
  account:show

Example output

{
 "privateKey": "a00c8107d40a8a678b5e9f4533bd4e740c446a1967300139b16fd62b0184cad51dc86a88278ee6db12ff671318677ec23b9ee6231cfca71a2c99c2ab78338cb1",
 "publicKey": "1dc86a88278ee6db12ff671318677ec23b9ee6231cfca71a2c99c2ab78338cb1",
 "address": "klyna5m2sa9p5u6nu8p7msnmsp6227vo2nrzvczsq",
 "binaryAddress": "3e565c6f2d22e0a3c1e4717672ec8ac61c2660f2"
}

Generate

Commands to auto-generate different components of a blockchain client.

USAGE
  $ klayr generate:COMMAND

COMMANDS
  generate:asset   Creates an asset skeleton for the given module name, name and id.
  generate:module  Creates a module skeleton for the given name and id.
  generate:plugin  Creates custom plugin.

Generate asset

Creates an asset skeleton for the given module name, asset name, and ID.

USAGE
  $ klayr generate:asset MODULENAME ASSETNAME ASSETID

ARGUMENTS
  MODULENAME  Module name.
  ASSETNAME   Asset name.
  ASSETID     Asset Id.

OPTIONS
  -t, --template=template  Template to bootstrap the application. It will read from `.klayrrc.json` or use `klayr-ts` if not found.

EXAMPLES
  generate:asset moduleName assetName assetID
  generate:asset nft transfer 1

Generate module

Creates a module skeleton for the given name and ID.

USAGE
  $ klayr generate:module MODULENAME MODULEID

ARGUMENTS
  MODULENAME  Module name.
  MODULEID    Module Id, should be atleast 1000 or more

OPTIONS
  -t, --template=template  Template to bootstrap the application. It will read from `.klayrrc.json` or use `klayr-ts` if not found.

EXAMPLE
  generate:module nft 5000

Generate plugin

Creates a custom plugin for the given alias.

USAGE
  $ klayr generate:plugin ALIAS

ARGUMENTS
  ALIAS  Alias of the plugin.

OPTIONS
  -o, --output=output      Path to create the plugin.
  -t, --template=template  Template to bootstrap the application. It will read from `.klayrrc.json` or use `klayr-ts` if not found.
  --registry=registry      URL of a registry to download dependencies from.
  --standalone             Create a standalone plugin package.

EXAMPLES
  generate:plugin my-plugin
  generate:plugin my-plugin --standalone --output ./myplugin

Message

Commands relating to user messages.

USAGE
  $ klayr message:COMMAND

COMMANDS
  message:decrypt
  message:encrypt
  message:sign
  message:verify

Decrypt message

Decrypts a previously encrypted message from a given sender public key for a known nonce using your secret passphrase.

Important: As the secret passphrase is a sensitive input, it can be provided using one of the methods described in the Sensitive Inputs section. The encrypted message can be provided either directly as an argument, or by specifying a source with the –message option. If both the secret passphrase and the encrypted message are provided via stdin, the secret passphrase must be provided in the first line, and the encrypted message must be provided in the subsequent lines.

USAGE
  $ klayr message:decrypt SENDERPUBLICKEY NONCE [MESSAGE]

ARGUMENTS
  SENDERPUBLICKEY  Public key of the sender of the message.
  NONCE            Nonce used during encryption.
  MESSAGE          Encrypted message.

OPTIONS
  -j, --[no-]json
      Prints output in JSON format. You can change the default behavior in your config.json file.

  -m, --message=message
      Specifies a source for providing a message to the command. If a string is provided directly as an argument, this option will be
      ignored. The message must be provided via an argument or via this option. Sources must be one of `file` or `stdin`. In the case
      of `file`, a corresponding identifier must also be provided.
      	Note: if both secret passphrase and message are passed via stdin, the passphrase must be the first line.
      	Examples:
      	- --message=file:/path/to/my/message.txt
      	- --message="hello world"

  -p, --passphrase=passphrase
      Specifies a source for your secret passphrase. Command will prompt you for input if this option is not set.
      	Examples:
      	- --passphrase='my secret passphrase' (should only be used where security is not important)

  --[no-]pretty
      Prints JSON in pretty format rather than condensed. Has no effect if the output is set to table. You can change the default
      behavior in your config.json file.

DESCRIPTION
  Decrypts a previously encrypted message from a given sender public key for a known nonce using your secret passphrase.

EXAMPLE
  message:decrypt bba7e2e6a4639c431b68e31115a71ffefcb4e025a4d1656405dfdcd8384719e0 4b800d90d54eda4d093b5e4e6bf9ed203bc90e1560bd628d dcaa605af45a4107a699755237b4c08e1ef75036743d7e4814dea7

Example JSON output

{
    "message": "My very secret message"
}

Encrypt message

This encrypts a message for a given recipient public key using your secret passphrase.

This command uses the Klayr Elements passphrase module to encrypt a message you provide for a given public key using a randomly generated nonce. In order to decrypt the encrypted message later the recipient will need your public key, (in order to verify that the message came from you), including the nonce and the secret passphrase which matches the specified public key.

Important: As the secret passphrase is a sensitive input, it can be provided using one of the methods described in the Sensitive Inputs section. The encrypted message can be provided either directly as an argument, or by specifying a source with the –message option. If both the secret passphrase and the encrypted message are provided via stdin, the secret passphrase must be provided in the first line, and the encrypted message must be provided in the subsequent lines.

USAGE
  $ klayr message:encrypt RECIPIENTPUBLICKEY [MESSAGE]

ARGUMENTS
  RECIPIENTPUBLICKEY  Public key of the recipient of the message.
  MESSAGE             Message to encrypt.

OPTIONS
  -j, --[no-]json
      Prints output in JSON format. You can change the default behavior in your config.json file.

  -m, --message=message
      Specifies a source for providing a message to the command. If a string is provided directly as an argument, this option will be ignored. The message must be provided via an argument or via this option. Sources must be one of `file` or
      `stdin`. In the case of `file`, a corresponding identifier must also be provided.
      	Note: if both secret passphrase and message are passed via stdin, the passphrase must be the first line.
      	Examples:
      	- --message=file:/path/to/my/message.txt
      	- --message="hello world"

  -p, --passphrase=passphrase
      Specifies a source for your secret passphrase. Command will prompt you for input if this option is not set.
      	Examples:
      	- --passphrase='my secret passphrase' (should only be used where security is not important)

  --[no-]pretty
      Prints JSON in pretty format rather than condensed. Has no effect if the output is set to table. You can change the default behavior in your config.json file.

DESCRIPTION
  Encrypts a message for a given recipient public key using your secret passphrase.

EXAMPLE
  message:encrypt bba7e2e6a4639c431b68e31115a71ffefcb4e025a4d1656405dfdcd8384719e0 "Hello world"

Example output

╔════════════════════╤══════════════════════════════════════════════════════════════════╗
║ nonce              │ 30809550cb5b6ff216ff54b15478a2fe2504b94b14c1b769                 ║
╟────────────────────┼──────────────────────────────────────────────────────────────────╢
║ encryptedMessage   │ 13bde81028e8ef57d901a52b2f0abec54624c761c32b625725b7be           ║
╟────────────────────┼──────────────────────────────────────────────────────────────────╢
║ recipientPublicKey │ bba7e2e6a4639c431b68e31115a71ffefcb4e025a4d1656405dfdcd8384719e0 ║
╚════════════════════╧══════════════════════════════════════════════════════════════════╝

Sign message

Signs a message using your secret passphrase.

This command signs the message. Your specific passphrase is required here.

Important: As the secret passphrase is a sensitive input, it can be provided using one of the methods described in the Sensitive Inputs section. The encrypted message can be provided either directly as an argument, or by specifying a source with the –message option. If both the secret passphrase and the encrypted message are provided via stdin, the secret passphrase must be provided in the first line, and the encrypted message must be provided in the subsequent lines.

USAGE
  $ klayr message:sign [MESSAGE]

ARGUMENTS
  MESSAGE  Message to sign.

OPTIONS
  -j, --[no-]json
      Prints output in JSON format. You can change the default behavior in your config.json file.

  -m, --message=message
      Specifies a source for providing a message to the command. If a string is provided directly as an argument, this option will be ignored. The message must be provided via an argument or via this option. Sources must be one of `file` or
      `stdin`. In the case of `file`, a corresponding identifier must also be provided.
      	Note: if both secret passphrase and message are passed via stdin, the passphrase must be the first line.
      	Examples:
      	- --message=file:/path/to/my/message.txt
      	- --message="hello world"

  -p, --passphrase=passphrase
      Specifies a source for your secret passphrase. Command will prompt you for input if this option is not set.
      	Examples:
      	- --passphrase='my secret passphrase' (should only be used where security is not important)

  --[no-]pretty
      Prints JSON in pretty format rather than condensed. Has no effect if the output is set to table. You can change the default behavior in your config.json file.

DESCRIPTION
  Signs a message using your secret passphrase.

EXAMPLE
  message:sign "Hello world"

Example JSON output

{
  "message":"Hello world",
  "publicKey": {
    "type":"Buffer",
    "data":[174,58,164,8,181,249,93,155,182,211,4,222,143,67,127,175,119,248,52,110,148,128,32,161,14,82,222,212,90,117,6,125]},"signature":{"type":"Buffer","data":[125,8,61,132,237,240,197,194,37,132,91,135,229,28,139,65,9,169,236,99,139,205,84,114,202,205,50,2,188,160,94,34,20,200,78,236,113,90,31,119,174,0,21,0,63,175,149,238,219,160,55,174,156,245,85,43,208,24,20,111,116,110,180,9]
  }
}

Verify message

Verifies a signature for a message using the signer’s public key.

This command verifies a message after being signed with the sign message command. The public key, signature and message are required.

USAGE
  $ klayr message:verify PUBLICKEY SIGNATURE [MESSAGE]

ARGUMENTS
  PUBLICKEY  Public key of the signer of the message.
  SIGNATURE  Signature to verify.
  MESSAGE    Message to verify.

OPTIONS
  -j, --[no-]json
      Prints output in JSON format. You can change the default behavior in your config.json file.

  -m, --message=message
      Specifies a source for providing a message to the command. If a string is provided directly as an argument, this option will be ignored. The message must be provided via an argument or via this option. Sources must be one of `file` or
      `stdin`. In the case of `file`, a corresponding identifier must also be provided.
      	Note: if both secret passphrase and message are passed via stdin, the passphrase must be the first line.
      	Examples:
      	- --message=file:/path/to/my/message.txt
      	- --message="hello world"

  --[no-]pretty
      Prints JSON in pretty format rather than condensed. Has no effect if the output is set to table. You can change the default behavior in your config.json file.

DESCRIPTION
  Verifies a signature for a message using the signer’s public key.

EXAMPLE
  message:verify 647aac1e2df8a5c870499d7ddc82236b1e10936977537a3844a6b05ea33f9ef6 2a3ca127efcf7b2bf62ac8c3b1f5acf6997cab62ba9fde3567d188edcbacbc5dc8177fb88d03a8691ce03348f569b121bca9e7a3c43bf5c056382f35ff843c09 "Hello world"

Example JSON output

 {
    "verified": true
}

Passphrase

Commands relating to Klayr passphrases.

USAGE
  $ klayr passphrase:COMMAND

COMMANDS
  passphrase:decrypt  Decrypt secret passphrase using the password provided at the time of encryption.
  passphrase:encrypt  Encrypt secret passphrase using password.

Decrypt passphrase

Decrypts your secret passphrase using the password which was provided at the time of encryption.

The following command listed below decrypts your secret passphrase after being encrypted with the encrypted passphrase command. The password which was used to encrypt the secret passphrase, as well as the initialisation vector (IV), which was randomly generated at the time of encryption will be required here:

Important: As the secret passphrase is a sensitive input, it can be provided using one of the methods described in the Sensitive Inputs section. The encrypted message can be provided either directly as an argument, or by specifying a source with the –message option. If both the secret passphrase and the encrypted message are provided via stdin, the secret passphrase must be provided in the first line, and the encrypted message must be provided in the subsequent lines.

USAGE
  $ klayr passphrase:decrypt ENCRYPTEDPASSPHRASE

ARGUMENTS
  ENCRYPTEDPASSPHRASE  Encrypted passphrase to decrypt.

OPTIONS
  -w, --password=password  Specifies a source for your secret password. Command will prompt you for input if this option is not set.
                           	Examples:
                           	- --password=pass:password123 (should only be used where security is not important)

  --pretty                 Prints JSON in pretty format rather than condensed.

EXAMPLES
  passphrase:decrypt "iterations=1000000&cipherText=9b1c60&iv=5c8843f52ed3c0f2aa0086b0&salt=2240b7f1aa9c899894e528cf5b600e9c&tag=23c01112134317a63bcf3d41ea74e83b&version=1"
  passphrase:decrypt "iterations=1000000&cipherText=9b1c60&iv=5c8843f52ed3c0f2aa0086b0&salt=2240b7f1aa9c899894e528cf5b600e9c&tag=23c01112134317a63bcf3d41ea74e83b&version=1" --password your-password

Example JSON output

{
    "passphrase": "minute omit local rare sword knee banner pair rib museum shadow juice"
}

Encrypt passphrase

Encrypts your secret passphrase under a password.

This command uses AES-256-CBC to encrypt your secret passphrase under a password you provide using a randomly generated initialisation vector (IV). In order to decrypt the secret passphrase later you will need both the IV and the password.

Important: As the secret passphrase is a sensitive input, it can be provided using one of the methods described in the Sensitive Inputs section. The encrypted message can be provided either directly as an argument, or by specifying a source with the –message option. If both the secret passphrase and the encrypted message are provided via stdin, the secret passphrase must be provided in the first line, and the encrypted message must be provided in the subsequent lines.

USAGE
  $ klayr passphrase:encrypt

OPTIONS
  -p, --passphrase=passphrase  Specifies a source for your secret passphrase. Command will prompt you for input if this option is not set.
                               	Examples:
                               	- --passphrase='my secret passphrase' (should only be used where security is not important)

  -w, --password=password      Specifies a source for your secret password. Command will prompt you for input if this option is not set.
                               	Examples:
                               	- --password=pass:password123 (should only be used where security is not important)

  --output-public-key          Includes the public key in the output. This option is provided for the convenience of node operators.

  --pretty                     Prints JSON in pretty format rather than condensed.

EXAMPLES
  passphrase:encrypt
  passphrase:encrypt --passphrase your-passphrase
  passphrase:encrypt --password your-password
  passphrase:encrypt --password your-password --passphrase your-passphrase --pretty
  passphrase:encrypt --output-public-key

Example JSON output

{
  "encryptedPassphrase":"iterations=1000000&cipherText=b472f9ad7fe2f0ca636df9d6bbacb585aeea72c0ccfe7d983b89fd864179452f184b333a150c88a82059f6bdbc327af90f000c29cd49cb608afa3ee55fc6e39ce203ab2bd381f0d400499adb&iv=ff0a48ade9dec58e65ce463c&salt=3e725655193277d49942da324fa0ed66&tag=cd6d9aabff7cac4a83b2e69386452a56&version=1"
}