SatLayer CLI

The SatLayer CLI tool allows developers to deploy, update and query BVS. It is an useful tool during development and avoids the complication of interacting with BVS/SatLayer's core contracts using the raw babylond command.

The SatLayer CLI tool is constructed on top of the ChainIO library, with just a minimal layer of code for handling user inputs. Everything the CLI can accomplish is also possible with ChainIO.

Installing SatLayer CLI

The SatLayer CLI is written in the Go programming language. Hence the Go compiler is needed in order to build the CLI tool. Methods to install golang differ depending on the operating system you are using. Generally, please follow the instructions on the Golang install page to install the Go compiler.

For Linux users, follow the installation instructions according to the distribution you are using. For Ubuntu and other Debian-based system, run:

sudo apt-get install golang-go

For Arch based systems, run:

sudo pacman -S go

For Fedora and other RHEL based systems, run:

sudo dnf install golang

With the Golang compiler installed, run the following to build the SatLayer CLI.

git clone https://github.com/satlayer/devnet-satlayer-cli
cd devnet-satlayer-cli

# Modify go.mod to as satlayer-api is not public yet (will be!)
echo "\nreplace github.com/satlayer/satlayer-api v0.3.0 => /path/to/your/clone/of/devnet-satlayer-api" >> go.mod
go build

By default the satlayer-cli uses the os keyring backend. This allows key sharing between the Babylon command line and satlayer-cli. Enabling seamless inter-operation. Please refer to Cosmos's Keyring document for details.

Installation

satlayer-cli can be installed by running go install. This installs the built result into golang's default installation directory.

go install

This installs to $HOME/go/bin. Please make sure to have this path added to your PATH environment variable. Please make sure the directory is in your system's PATH environment variable. For UNIX users (Linux, MacOS, etc..)

# ~/.bashrc or ~/.zshrc
export PATH=$HOME/go/bin:$PATH

Then source your shell rc scrip or start a new shell to active it.

source ~/.bashrc
# or
source ~/.zshrc

On Windows or UNIX with PowerShell you should edit the $profile file (run echo $profile in PowerShell to acquire the file path) and append the following.

# Edit $profile
$env:Path = $env:UserProfile+[IO.Path]::PathSeparator+"go"+[IO.Path]::PathSeparator+"bin;"+$env:Path

Close and start a new PowerShell session to activate the change.

Configuration

By default the configuration file is stored in $HOME/.config/satlayer/config.toml(or %USERPROFILE%\.config\satlayer\config.toml on Windows). You can set the SATLAYER_CONFIG environment variable to change where the configuration is loaded from. There is no need to set this variable if you wish to use the default configuration file path.

On *NIX (Linux, MacOS, etc..), assuming a BASH or DASH compatible shell:

# Demo command. the ... at the end is the rest of the command you wish to run
SATLAYER_CONFIG=/path/to/your/config.toml ./satlayer-cli ...

On Windows, or using PowerShell on *NIX, remember to Remove-Item afterwards as PowerShell does not support temporary variables.

# Demo command. the ... at the end is the rest of the command you wish to run
$env:SATLAYER_CONFIG = "C:\path\to\your\config.toml"; ./satlayer-cli ...
Remove-Item env\SATLAYER_CONFIG

Command Structure

The SatLayer CLI is a monolithic program (in opposite to how most classic UNIX commands) with layered sub-commands.

Commands are in the format of the following.

  • Subcommands could be layered and flags follows the UNIX convention. A double dash (--) is used for long names and a single dash (-) is used for short, single character flags and options.

./satlayer-cli [subcommand 1 [subcommand 2 [subcommand 3] ...]] [-f --flags]  

Notation conversion

We follow the convention of what is used by most GNU and BSD commands:

  • Optional parameters are enclosed in [square-brackets]

  • Required parameters are free-formed without-any-decoration

  • Template/string expected to be provided by user is in <angle-brackets>

  • Flags/options can be followed by zero or more parameters. For example

    • -v in a flag with no parameters

    • -f <path-to-file>is an option that accepts a parameter

    • -c <files>... indicates it accepts multiple parameters

For example, my-command read -f <path-to-file> [-v] indicates:

  • The command name is my-command

  • The subcommand is read and is mandatory

  • The -f option is required and it is followed by a path to a file

  • And the -v option is optional without any parameter following it.

Built-in help

Every command and sub-commands of the SatLayer CLI includes built-in help message for quick access.

They can be displayed by either running the help subcommand or via the --help or -h flag. They generally follow the same notation used in this document.

For example:

❯ ./satlayer-cli chain -h
Chain related commands

Usage:
  satlayer chain [command]

Available Commands:
  get-account To query the account.
  get-node    To query the node status info.
  get-txn     To query the transaction.

Flags:
  -h, --help   help for chain

Common parameters

The user-key-name parameter is very common among commands. To reduce the amount of text in the document. The option will not be described in each command documentation. user-key-name is a mandatory parameter that specifies which key in the keyring is used to invoke a contract.

Last updated