Babylon CLI

Babylon Chain's Command Line Tool

As SatLayer is built on Babylon, we will often need to interact with Babylon Chain. Sometimes we need to utilize the low-level cli tool babylond during development. This document serves as a centralized resource for getting and installing babylond as well as commonly used operations.

Please note that this is not an exhaustive list of the commands supported by Babylon.

Installing babylond

In order to compile Babylon, Go >= 1.21 should be installed. 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
  1. Clone Babylon source code repo and cd into the directory

git clone https://github.com/babylonchain/babylon.git
cd babylon
  1. To build the binary, execute

make build

After compiling, you can find the binary in ./build/babylond.

  1. Install babylond

To install the binary to your user's directories, execute the following. This command installs babylond to Golang's default install directory $HOME/go/bin. Please make sure to have this path added to your PATH environment variable.

Then add $HOME/go/bin to PATH. For UNIX users (Linux, MacOS, etc..)

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

Or 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.

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

Key Operations

babylond allows the management of keys. Common operations include create, delete, export, import and listing keys. Multiple keyring backends are supported.

By default, babylond asks the OS to handle key storage. But other options are available, mostly for development purposes.

Deleting Keys

To delete keys, run this command:

Printing keys

The keys export sub-comamnd prints the key:

Importing keys

Key import is also supported via this command:

Listing keys

To list all keys stored in the keyring:

Query

query houses subcommands that queries specific information. The most common queries are for account balances, transaction information and smart contract states. These operations requires communication with a Babylon node. The --node parameter specifics the Babylon (RPC) node to use. And the --chain-id specifics the chain ID. For testnet, these 2 parameters must be specified correctly in order for the command to work at all.

To query a past transaction

Not all nodes are so-called archiver nodes. Non-archive node will truncate chain history to reduce storage space needed by the node software. Querying an old transaction against an non-archiver may result in the transaction not being found or an error.

To query the state of a smart contract

CosmWasm

Babylon supports CosmWasm smart contracts. The wasm subcommands deals with related operations.

Like the query subcommand above, --node and --chain-id are needed when use on a testnet. In addition, they are required for gas controlling parameters to limit the maximal gas spent on the operation.

After uploading the WASM binary, a contact needs to be instantiated from the binary:

CosmWasm contracts separate query and execute functions, distinguishing between read-only and mutable operations. Queries are free, while executing a contract requires gas.

In addition, EVM and contracts on CosmWasm can be upgraded (if migrate is enabled)

Others

The tx bank send command sends token from one address (you must own the private key) to another. The same node, chain and gas parameters apply here too.

Reference

You can use ./babylond --help to get full documentations about how to use babylon command line or through the official Babylon documentation.

Last updated