# Library commands · Chromia Docs (concept)

> The Library commands provide a CLI interface for discovering and installing libraries from the Chromia library registry.

Source: https://docs.chromia.com/build/cli/library/

# Library commands

On this page

* [library list](#library-list)
* [library view](#library-view)
* [library versions](#library-versions)
* [library install](#library-install)
* [Configuration](#configuration)
* [Common options](#common-options)

The Library commands provide a CLI interface for discovering and installing libraries from the Chromia library registry.
These commands allow developers to browse available Rell libraries and integrate them into their projects.

info

The Library Chain is a complete dapp deployed on the Chromia blockchain that hosts the library registry. You can explore
it on the
[Chromia Explorer](https://explorer.chromia.com/mainnet/C9051571CD822507DDD1F3B43F2DC066B54CC5A25ECD758A1B5A42913483CF20)

## library list

List all available libraries in the registry.

**Usage:**

Terminal

```
chr library list [options]
```

**Options:**

* `--limit <number>`, `-l <number>`: Maximum number of libraries to display (default: 10)
* `--offset <number>`, `-o <number>`: Number of libraries to skip (default: 0)
* `--sort-by <order>`: Sort order (`asc` or `desc`, default: `desc`)

**Example:**

Terminal

```
chr library list
```

## library view

View detailed information about a specific library.

**Usage:**

Terminal

```
chr library view <library_id> [options]
```

**Arguments:**

* `library_id`: ID of the library to view

**Example:**

Terminal

```
chr library view com.chromia.ft4
```

## library versions

List all versions of a specific library.

**Usage:**

Terminal

```
chr library versions <library_id> [options]
```

**Arguments:**

* `library_id`: ID of the library to list versions for

**Options:**

* `--limit <number>`, `-l <number>`: Maximum number of versions to display (default: 10)
* `--offset <number>`, `-o <number>`: Number of versions to skip (default: 0)

**Example:**

Terminal

```
chr library versions com.chromia.ft4
```

## library install

Install libraries from the registry to your local project.

The `library install` command reads your `chromia.yml` file and installs all libraries defined in the `libs` section. It
supports both library-chain libraries (published to Chromia's library registry) and external Git libraries.

**Usage:**

Terminal

```
chr library install <library_id> [options]
```

**Arguments:**

* `library_id` (optional): Specific library ID to install. If not provided, all configured libraries in `chromia.yml`
  will be installed.

**Options:**

* `--force`, `-f`: Force installation even if RID verification fails (use with caution)

warning

When using the `--force` flag, the RID verification is skipped. This is not recommended as it can lead to security
vulnerabilities.

### Configuration

Libraries are configured in your `chromia.yml` file using the `libs` section:

#### Library-chain libraries

Published to Chromia's library registry:

YAML

```
libs:
  com.chromia.ft4: # Library from Chromia's library-chain registry
    version: 0.0.1
```

**Configuration options:**

* `version`: Version of the library to install

#### External Git libraries

Hosted in Git repositories:

YAML

```
libs:
  ft4: # External library from Git
    registry: https://gitlab.com/chromaway/ft4-lib.git
    path: rell/src/lib/ft4
    tagOrBranch: v1.2.0r
    rid: x"E96915FD7C9A5DD4E183D86F4A5B4BB5083A7CC1EDEB1465EDFFC926E67C93F6"
    insecure: false
```

**Configuration options:**

* `registry`: Git repository URL
* `path`: Path within the repository to the library
* `tagOrBranch`: Git tag or branch to use
* `rid`: Expected RID for verification
* `insecure`: Skip RID verification (not recommended)

#### Installation examples

**Install all configured libraries:**

Terminal

```
chr library install
```

**Install a specific library:**

Terminal

```
chr library install com.chromia.ft4
```

note

It installs the latest version of the library. It will print message like this:

Terminal

```
add this into chromia.yaml file under libs :
com.chromia.ft4
        version: 1.0.0
```

* you have to add this into chromia.yaml file under libs

**Install a specific version:**

Terminal

```
chr library install com.chromia.ft4@1.0.0
```

**Install latest version:**

Terminal

```
chr library install com.chromia.ft4
```

**Force installation:**

Terminal

```
chr library install com.chromia.ft4 --force
```

warning

Use the `--force` flag with caution, as it bypasses RID verification which is an important security measure.

#### Using installed libraries

Once installed, you can import and use libraries in your Rell code. Libraries are imported using their simple name:

Rell

```
import ft4;

// Use library functions
val result = ft4.some_function();
```

note

When importing libraries in Rell code, use the library's simple name (e.g., `ft4`) rather than the full library ID
(e.g., `com.chromia.ft4`).

## Common options

All library commands inherit common options for connecting to the library-chain:

**Connection options:**

* `--url <url>`: URL to the target node. Only required if library-chain is deployed on a custom network (e.g.,
  `https://custom-network`). Defaults to Chromia's mainnet if not provided.
* `--brid <hex>`: Blockchain RID of the library-chain. Only required if library-chain is deployed on a custom network.

**Examples of common usage patterns:**

Terminal

```
chr library <command> [options]
```

[View this page on docs.chromia.com](https://docs.chromia.com/build/cli/library/)Content mirrored from the live docs
