Rust CLI Commands
For a full tutorial on how to get started with Layer and run an example AVS, follow the setup guide.
The Rust CLI is used to interact with various components on layer, primarily by way of sending queries and transactions to the chain.
Installing the CLI
The only thing you need is a Rust compiler. The exact way to install will depend on your operating system, but in general you can use the rustup
tool:
bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Check out the official Rust installation site for more information: https://www.rust-lang.org/tools/install
You could also skip to the next step and run:
scripts/setup_wasi.sh
to install the necessary dependencies.
Cloning the Repository
Use the following command to clone the Layer AVS toolkit repository: https://github.com/Lay3rLabs/avs-toolkit
git clone --branch v0.2.1 --depth 1 https://github.com/Lay3rLabs/avs-toolkit.git
This command will create a new directory called avs-toolkit
in your current directory.
Install
From within the [avs-toolkit](https://github.com/Lay3rLabs/avs-toolkit)
directory, navigate to tools/cli
:
cd avs-toolkit/tools/cli
And then install the CLI using Cargo:
cargo install --path .
It will take some time to finish. When completed, you should be able to run the CLI from anywhere on your system:
avs-toolkit-cli --version
Environment Variables
Wherever you use the CLI, it will load variables like the mnemonic from your environment. The exact way you set it will depend on your project, your operating system, and maybe even your specific terminal.
For example, taking the TEST_MNEMONIC
environment variable, you might set it in your .bashrc
or .bash_profile
:
export TEST_MNEMONIC="your mnemonic here"
However, if you set it in a .env
file and run avs-toolkit-cli
from that directory, it will pick up the variable automatically.
Example .env
file:
TEST_MNEMONIC="your mnemonic here"
Creating a Wallet
The CLI is a powerful tool that can be used to interact with the chain. Most of the fun stuff will require that you have a wallet with some funds in it, so let's create that first:
avs-toolkit-cli wallet create
This will create a new wallet and print out the "mnemonic". Make sure to write this down and keep it safe!
Making the Wallet Available
The CLI will look for the mnemonic in the TEST_MNEMONIC
or LOCAL_MNEMONIC
environment variable, depending on the environment you're targeting.
See the Environment Variables section for more information on setting these up.
You'll know you've set it up properly when this command shows an address:
avs-toolkit-cli wallet show
Giving the Wallet Some Funds
Right now, you probably don't have any funds in your wallet. You can get some from the faucet by following the steps below.
You'll need to install Telegram in order to get faucet funds for the hacknet. Visit https://telegram.org/ and follow installation instructions for your device.
- After installing Telegram, Visit https://t.me/LayerUp_bot to open the LayerUp Telegram app.
- Click Start and then Start adventure.
- After following the prompts in the app, you'll be able to open the menu in the left corner of the screen. Click the illuminated drop-shaped button.
- Scroll down and input your wallet address. You can use the following command in the CLI to view your address:
avs-toolkit-cli wallet show
- Click Claim Tokens after entering your wallet address. The faucet tokens will be sent to your wallet.
If you run the following in the CLI, you should see some funds in your wallet.
avs-toolkit-cli wallet show
Transfering funds
You can transfer funds to another account using the following command:
avs-toolkit-cli wallet transfer --to <recipient_address> --amount <amount>
This will transfer the specified amount to the recipient address.
As an alternative to wallet show
, you can see the balance of any address using the following command:
avs-toolkit-cli wallet balance --address <address>
Alright, you made it, you've got a well-funded wallet and you're ready to start interacting with the chain. Let's go!