github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/gno-tooling/cli/gnokey.md (about)

     1  ---
     2  id: gno-tooling-gnokey
     3  ---
     4  
     5  # gnokey
     6  
     7  Used for account & key management and general interactions with the Gnoland blockchain.
     8  
     9  ## Generate a New Seed Phrase
    10  
    11  Generate a new seed phrase and add it to your keybase with the following command.
    12  
    13  ```bash
    14  gnokey generate
    15  ```
    16  
    17  ## Add a New Key
    18  
    19  You can add a new private key to the keybase using the following command.
    20  
    21  ```bash
    22  gnokey add {KEY_NAME}
    23  ```
    24  
    25  #### **Options**
    26  
    27  | Name        | Type       | Description                                                                            |
    28  |-------------|------------|----------------------------------------------------------------------------------------|
    29  | `account`   | UInt       | Account number for HD derivation.                                                      |
    30  | `dryrun`    | Boolean    | Performs action, but doesn't add key to local keystore.                                |
    31  | `index`     | UInt       | Address index number for HD derivation.                                                |
    32  | `ledger`    | Boolean    | Stores a local reference to a private key on a Ledger device.                          |
    33  | `multisig`  | String \[] | Constructs and stores a multisig public key (implies `--pubkey`).                      |
    34  | `nobackup`  | Boolean    | Doesn't print out seed phrase (if others are watching the terminal).                   |
    35  | `nosort`    | Boolean    | Keys passed to `--multisig` are taken in the order they're supplied.                   |
    36  | `pubkey`    | String     | Parses a public key in bech32 format and save it to disk.                              |
    37  | `recover`   | Boolean    | Provides seed phrase to recover existing key instead of creating.                      |
    38  | `threshold` | Int        | K out of N required signatures. For use in conjunction with --multisig (default: `1`). |
    39  
    40  > **Test Seed Phrase:** source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast
    41  
    42  ### Using a ledger device
    43  
    44  You can add a ledger device using the following command
    45  
    46  > [!NOTE]
    47  > Before running this command make sure your ledger device is connected, with the cosmos app installed and open in it.
    48  
    49  ```bash
    50  gnokey add {LEDGER_KEY_NAME} --ledger
    51  ```
    52  
    53  ## List all Known Keys
    54  
    55  List all keys stored in your keybase with the following command.
    56  
    57  ```bash
    58  gnokey list
    59  ```
    60  
    61  ## Delete a Key
    62  
    63  Delete a key from your keybase with the following command.
    64  
    65  ```bash
    66  gnokey delete {KEY_NAME}
    67  ```
    68  
    69  #### **Options**
    70  
    71  | Name    | Type    | Description                  |
    72  |---------|---------|------------------------------|
    73  | `yes`   | Boolean | Skips confirmation prompt.   |
    74  | `force` | Boolean | Removes key unconditionally. |
    75  
    76  
    77  ## Export a Private Key (Encrypted & Unencrypted)
    78  
    79  Export a private key's (encrypted or unencrypted) armor using the following command.
    80  
    81  ```bash
    82  gnokey export
    83  ```
    84  
    85  #### **Options**
    86  
    87  | Name          | Type   | Description                                 |
    88  |---------------|--------|---------------------------------------------|
    89  | `key`         | String | Name or Bech32 address of the private key   |
    90  | `output-path` | String | The desired output path for the armor file  |
    91  | `unsafe`      | Bool   | Export the private key armor as unencrypted |
    92  
    93  
    94  ## Import a Private Key (Encrypted & Unencrypted)
    95  
    96  Import a private key's (encrypted or unencrypted) armor with the following command.
    97  
    98  ```bash
    99  gnokey import
   100  ```
   101  
   102  #### **Options**
   103  
   104  | Name         | Type   | Description                                 |
   105  |--------------|--------|---------------------------------------------|
   106  | `armor-path` | String | The path to the encrypted armor file.       |
   107  | `name`       | String | The name of the private key.                |
   108  | `unsafe`     | Bool   | Import the private key armor as unencrypted |
   109  
   110  
   111  ## Make an ABCI Query
   112  
   113  Make an ABCI Query with the following command.
   114  
   115  ```bash
   116  gnokey query {QUERY_PATH}
   117  ```
   118  
   119  #### **Query**
   120  
   121  | Query Path                | Description                                                        | Example                                                                                |
   122  |---------------------------|--------------------------------------------------------------------|----------------------------------------------------------------------------------------|
   123  | `auth/accounts/{ADDRESS}` | Returns information about an account.                              | `gnokey query auth/accounts/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5`                  |
   124  | `bank/balances/{ADDRESS}` | Returns balances of an account.                                    | `gnokey query bank/balances/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5`                  |
   125  | `vm/qfuncs`               | Returns public facing function signatures as JSON.                 | `gnokey query vm/qfuncs --data "gno.land/r/demo/boards"`                               |
   126  | `vm/qfile`                | Returns the file bytes, or list of files if directory.             | `gnokey query vm/qfile --data "gno.land/r/demo/boards"`                                |
   127  | `vm/qrender`              | Calls .Render(path) in readonly mode.                              | `gnokey query vm/qrender --data "gno.land/r/demo/boards"`                              |
   128  | `vm/qeval`                | Evaluates any expression in readonly mode and returns the results. | `gnokey query vm/qeval --data "gno.land/r/demo/boards GetBoardIDFromName("my_board")"` |
   129  | `vm/store`                | (not yet supported) Fetches items from the store.                  | -                                                                                      |
   130  | `vm/package`              | (not yet supported) Fetches a package's files.                     | -                                                                                      |
   131  
   132  #### **Options**
   133  
   134  | Name     | Type      | Description                              |
   135  |----------|-----------|------------------------------------------|
   136  | `data`   | UInt8 \[] | Queries data bytes.                      |
   137  | `height` | Int64     | (not yet supported) Queries height.      |
   138  | `prove`  | Boolean   | (not yet supported) Proves query result. |
   139  
   140  
   141  ## Sign and Broadcast a Transaction
   142  
   143  You can sign and broadcast a transaction with the following command.
   144  
   145  ```bash
   146  gnokey maketx {SUB_COMMAND} {ADDRESS or KeyName}
   147  ```
   148  
   149  #### **Subcommands**
   150  
   151  | Name     | Description                  |
   152  |----------|------------------------------|
   153  | `addpkg` | Uploads a new package.       |
   154  | `call`   | Calls a public function.     |
   155  | `send`   | The amount of coins to send. |
   156  
   157  ### `addpkg`
   158  
   159  This subcommand lets you upload a new package.
   160  
   161  ```bash
   162  gnokey maketx addpkg \
   163      -deposit="1ugnot" \
   164      -gas-fee="1ugnot" \
   165      -gas-wanted="5000000" \
   166      -pkgpath={Registered Realm path} \
   167      -pkgdir={Package folder path} \
   168      {ADDRESS} \
   169      > unsigned.tx
   170  ```
   171  
   172  #### **SignBroadcast Options**
   173  
   174  | Name         | Type    | Description                                                                            |
   175  |--------------|---------|----------------------------------------------------------------------------------------|
   176  | `gas-wanted` | Int64   | The maximum amount of gas to use for the transaction.                                  |
   177  | `gas-fee`    | String  | The gas fee to pay for the transaction.                                                |
   178  | `memo`       | String  | Any descriptive text.                                                                  |
   179  | `broadcast`  | Boolean | Broadcasts the transaction.                                                            |
   180  | `chainid`    | String  | The chainid to sign for (should only be used with `--broadcast`)                       |
   181  | `simulate`   | String  | One of `test` (default), `skip` or `only` (should only be used with `--broadcast`)[^1] |
   182  
   183  #### **makeTx AddPackage Options**
   184  
   185  | Name      | Type   | Description                           |
   186  |-----------|--------|---------------------------------------|
   187  | `pkgpath` | String | The package path (required).          |
   188  | `pkgdir`  | String | The path to package files (required). |
   189  | `deposit` | String | The amount of coins to send.          |
   190  
   191  ### `call`
   192  
   193  This subcommand lets you call a public function.
   194  
   195  ```bash
   196  # Register
   197  gnokey maketx call \
   198      -gas-fee="1ugnot" \
   199      -gas-wanted="5000000" \
   200      -pkgpath="gno.land/r/demo/users" \
   201      -send="200000000ugnot" \
   202      -func="Register" \
   203      -args="" \
   204      -args={NAME} \
   205      -args="" \
   206      {ADDRESS} \
   207      > unsigned.tx
   208  ```
   209  
   210  #### **SignBroadcast Options**
   211  
   212  | Name         | Type    | Description                                                                            |
   213  |--------------|---------|----------------------------------------------------------------------------------------|
   214  | `gas-wanted` | Int64   | The maximum amount of gas to use for the transaction.                                  |
   215  | `gas-fee`    | String  | The gas fee to pay for the transaction.                                                |
   216  | `memo`       | String  | Any descriptive text.                                                                  |
   217  | `broadcast`  | Boolean | Broadcasts the transaction.                                                            |
   218  | `chainid`    | String  | The chainid to sign for (should only be used with `--broadcast`)                       |
   219  | `simulate`   | String  | One of `test` (default), `skip` or `only` (should only be used with `--broadcast`)[^1] |
   220  
   221  #### **makeTx Call Options**
   222  
   223  | Name      | Type   | Description                                                                                                                                          |
   224  |-----------|--------|------------------------------------------------------------------------------------------------------------------------------------------------------|
   225  | `send`    | String | The amount of coins to send.                                                                                                                         |
   226  | `pkgpath` | String | The package path (required).                                                                                                                         |
   227  | `func`    | String | The contract to call (required).                                                                                                                     |
   228  | `args`    | String | An argument of the function being called. Can be used multiple times in a single `call` command to accommodate possible multiple function arguments. |
   229  
   230  :::info
   231  Currently, only primitive types are supported as `-args` parameters. This limitation will be addressed in the future.
   232  Alternatively, see how `maketx run` works.
   233  :::
   234  
   235  ### `send`
   236  
   237  This subcommand lets you send a native currency to an address.
   238  
   239  ```bash
   240  gnokey maketx send \
   241      -gas-fee="1ugnot" \
   242      -gas-wanted="5000000" \
   243      -send={SEND_AMOUNT} \
   244      -to={TO_ADDRESS} \
   245      {ADDRESS} \
   246      > unsigned.tx
   247  ```
   248  
   249  #### **SignBroadcast Options**
   250  
   251  | Name         | Type    | Description                                                                            |
   252  |--------------|---------|----------------------------------------------------------------------------------------|
   253  | `gas-wanted` | Int64   | The maximum amount of gas to use for the transaction.                                  |
   254  | `gas-fee`    | String  | The gas fee to pay for the transaction.                                                |
   255  | `memo`       | String  | Any descriptive text.                                                                  |
   256  | `broadcast`  | Boolean | Broadcasts the transaction.                                                            |
   257  | `chainid`    | String  | The chainid to sign for (should only be used with `--broadcast`)                       |
   258  | `simulate`   | String  | One of `test` (default), `skip` or `only` (should only be used with `--broadcast`)[^1] |
   259  
   260  #### **makeTx Send Options**
   261  
   262  | Name   | Type   | Description              |
   263  |--------|--------|--------------------------|
   264  | `send` | String | Amount of coins to send. |
   265  | `to`   | String | The destination address. |
   266  
   267  
   268  ## Sign a Document
   269  
   270  Sign a document with the following command.
   271  
   272  ```bash
   273  gnokey sign
   274  ```
   275  
   276  #### **Options**
   277  
   278  | Name             | Type    | Description                                                |
   279  |------------------|---------|------------------------------------------------------------|
   280  | `txpath`         | String  | The path to file of tx to sign (default: `-`).             |
   281  | `chainid`        | String  | The chainid to sign for (default: `dev`).                  |
   282  | `number`         | UInt    | The account number of the account to sign with (required)  |
   283  | `sequence`       | UInt    | The sequence number of the account to sign with (required) |
   284  | `show-signbytes` | Boolean | Shows signature bytes.                                     |
   285  
   286  
   287  ## Verify a Document Signature
   288  
   289  Verify a document signature with the following command.
   290  
   291  ```bash
   292  gnokey verify
   293  ```
   294  
   295  #### **Options**
   296  
   297  | Name      | Type   | Description                              |
   298  |-----------|--------|------------------------------------------|
   299  | `docpath` | String | The path of the document file to verify. |
   300  
   301  ## Broadcast a Signed Document
   302  
   303  Broadcast a signed document with the following command.
   304  
   305  ```bash
   306  gnokey broadcast {signed transaction file document}
   307  ```
   308  
   309  [^1]: `only` simulates the transaction as a "dry run" (ie. without committing to
   310    the chain), `test` performs simulation and, if successful, commits the
   311    transaction, `skip` skips simulation entirely and commits directly.