Subnet-cli - A command-line interface to manage Avalanche Subnets

Overview

subnet-cli

A command-line interface to manage Avalanche Subnets.

Install

git clone https://github.com/ava-labs/subnet-cli.git;
cd subnet-cli;
go install -v .;

Once you have installed subnet-cli, check the help page to confirm it is working as expected (make sure your $GOBIN is in your $PATH):

subnet-cli CLI

Usage:
  subnet-cli [command]

Available Commands:
  add         Sub-commands for creating resources
  completion  Generate the autocompletion script for the specified shell
  create      Sub-commands for creating resources
  help        Help about any command
  status      status commands

Flags:
      --enable-prompt              'true' to enable prompt mode (default true)
  -h, --help                       help for subnet-cli
      --log-level string           log level (default "info")
      --poll-interval duration     interval to poll tx/blockchain status (default 1s)
      --request-timeout duration   request timeout (default 2m0s)

Use "subnet-cli [command] --help" for more information about a command.

Usage

The following commands will walk you through creating a subnet on Fuji.

subnet-cli create VMID

This command is used to generate a valid VMID based on some string to uniquely identify a VM. This should stay the same for all versions of the VM, so it should be based on a word rather than the hash of some code.

subnet-cli create VMID <identifier> [--hash]

subnet-cli create key

subnet-cli create key

subnet-cli will assume you have funds on this key (or --private-key-path) on the P-Chain for the rest of this walkthrough.

The easiest way to do this (for testing only) is:

  1. Import your private key (.subnet-cli.pk) into the web wallet
  2. Request funds from the faucet
  3. Move the test funds (sent on either the X or C-Chain) to the P-Chain (Tutorial)

After following these 3 steps, your test key should now have a balance on the P-Chain.

subnet-cli create subnet

subnet-cli create subnet

To create a subnet in the local network:

subnet-cli create subnet \
--private-key-path=.insecure.ewoq.key \
--public-uri=http://localhost:55749

create-subnet-local-1 create-subnet-local-2

subnet-cli add validator

subnet-cli add validator \
--node-id="[YOUR-NODE-ID]" \
--subnet-id="[YOUR-SUBNET-ID]"

To add a validator with the local network:

subnet-cli add validator \
--private-key-path=.insecure.ewoq.key \
--public-uri=http://localhost:55749 \
--node-id="NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg" \
--subnet-id="24tZhrm8j8GCJRE9PomW8FaeqbgGS4UAQjJnqqn8pq5NwYSYV1"

add-validator-local-1 add-validator-local-2

subnet-cli create blockchain

subnet-cli create blockchain \
--subnet-id="[YOUR-SUBNET-ID]" \
--chain-name="[YOUR-CHAIN-NAME]" \
--vm-id="[YOUR-VM-ID]" \
--vm-genesis-path="[YOUR-VM-GENESIS-PATH]"

To create a blockchain with the local cluster:

subnet-cli create blockchain \
--private-key-path=.insecure.ewoq.key \
--public-uri=http://localhost:55749 \
--subnet-id="24tZhrm8j8GCJRE9PomW8FaeqbgGS4UAQjJnqqn8pq5NwYSYV1" \
--chain-name=test \
--vm-id=tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH \
--vm-genesis-path=/tmp/testvm.genesis

create-blockchain-local-1 create-blockchain-local-2

subnet-cli status blockchain

To check the status of the blockchain 2o5THyMs4kVfC42yAiSt2SrjWNkxCLYZef1kewkqYPEiBPjKtn from the private URI:

subnet-cli status blockchain \
--private-uri=http://localhost:55749 \
--blockchain-id="2o5THyMs4kVfC42yAiSt2SrjWNkxCLYZef1kewkqYPEiBPjKtn" \
--check-bootstrapped

See scripts/tests.e2e.sh and tests/e2e/e2e_test.go for example tests.

Running with local network

# [OPTIONAL]
# build avalanchego for local testing
cd ${HOME}/go/src/github.com/ava-labs/avalanchego
rm -rf ./build
./scripts/build.sh

# [OPTIONAL]
# build test runner for local cluster setup
cd ${HOME}/go/src/github.com/ava-labs/subnet-cli/tests/runner
go build -o /tmp/subnet-cli.runner -v .
/tmp/subnet-cli.runner \
--avalanchego-path ${HOME}/go/src/github.com/ava-labs/avalanchego/build/avalanchego \
--whitelisted-subnets="24tZhrm8j8GCJRE9PomW8FaeqbgGS4UAQjJnqqn8pq5NwYSYV1" \
--output-path /tmp/subnet-cli.runner.yml

# [OPTIONAL]
# get cluster endpoints to send requests to
cat /tmp/subnet-cli.runner.yml
uris:
- http://localhost:57574
...
Issues
  • SubnetCLI generates hex key and expects cb58 format

    SubnetCLI generates hex key and expects cb58 format

    The subnet-cli command subnet-cli create key generates a key in hex format as expected by MM, but then it expects the private key that it uses for other interactions to be in the PrivateKey-<CB58 string> format. We should fix this so that it either generates a private key in the expected format for interaction with the subnet-cli or allow the subnet-cli to read in both formats.

    opened by aaronbuchwald 5
  • Instructions for installing subnet-cli seem incomplete

    Instructions for installing subnet-cli seem incomplete

    I followed the steps outlined in the README.md and after running go install -v . and it seemingly downloading everything successfully I still get zsh: command not found: subnet-cli.

    I followed the steps here to set my GOBIN path unfortunately without success.

    Any pointers would be much appreciated. Thanks

    opened by tvongerlach 5
  • Fix upstream network-runner URL

    Fix upstream network-runner URL

    This PR fixes the format for the PK save function.

    Closes https://github.com/ava-labs/subnet-cli/issues/33

    Also fixes the upstream network-runner URL for E2E testing

    opened by holisticode 2
  • Easy hardcoded version info

    Easy hardcoded version info

    Add new command: print the version number and exit.

    closes https://github.com/ava-labs/subnet-cli/issues/32

    I have experimented with the goreleaser for a better version string but didn't resolve yet.

    NOTE: This version already returns 0.3.3 as version, which requires a new public and tag release after this is merged so that it matches.

    opened by holisticode 2
  • Error while creating new avalanche vm error during vm's Initialize: unknown codec version

    Error while creating new avalanche vm error during vm's Initialize: unknown codec version

    Hi, I have a local testnet running based on this tutorial https://docs.avax.network/build/tutorials/platform/create-a-local-test-network. And Genesis file fake-genesis.json has the same content as here https://docs.avax.network/build/tutorials/platform/subnets/create-avm-blockchain#create-the-genesis-data.

    • OS: Ubuntu 20.04
    • Avalanche: avalanche/1.7.4 [database=v1.4.5, commit=e388a890b6c02c0f58fd116357fe508e65bb1c42]

    I am using subnet-cli wizard to create a subnet and an avm blockchain:

    subnet-cli wizard --node-ids=NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg,NodeID-MFrZFVCXPv5iCn6M9K6XduxGTYp891xXZ,NodeID-NFBbbJ4qCmNaCzeW7sxErhvWqvEQMnYcN,NodeID-GWPcbFJZFfZreETSoWjPimr846mXEKCtu,NodeID-P7oB2McjBGgW2NXXWVYjV8JEDFoW9xDE5 --public-uri=http://127.0.0.1:9650 --vm-genesis-path=fake-genesis.json --vm-id=jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq --chain-name=mychain --private-key-path=./.insecure.ewoq.key
    

    This is the subnet-cli output everything seems fine:

    Screen Shot 2022-03-14 at 6 40 38 PM

    But all the validator nodes(5) are showing this error:

    ERROR[03-14|16:38:46] chains/manager.go#270: error creating chain 2TxnUundHxxjDGeN4rYJpGKxCPJkUEDMQgL5ewmpKPdsnFN1MZ: error while creating new avalanche vm error during vm's Initialize: unknown codec version
    

    Screen Shot 2022-03-14 at 6 44 11 PM

    opened by metmirr 1
  • Ledger Support

    Ledger Support

    To use your Ledger with subnet-cli, just add the -l/--ledger flag to any command below.

    Make sure you've downloaded the latest version of the Avalanche Ledger App first!

    opened by patrick-ogrady 1
  • *: replace

    *: replace "runner" with runner RPC server, "AddValidator"

    Proof-of-concept to replace runner code with network runner RPC server.

    https://github.com/gyuho/avax-tester/releases/tag/v0.0.2

    Now only require 20 lines of code to integrate with network-runner.

    TODO: migrate to upstream network runner.

    opened by gyuho 1
  • Having trouble getting started

    Having trouble getting started

    I'm trying to get a subnet running with a blockchain, but I'm new to the Avalanche ecosystem and having trouble figuring out where to get the node IDs from to run the subnet-cli wizard command. I read through the EVM blockchain creation docs to find the genesis JSON, and ran the subnet EVM, but none of that seems to work properly.

    It feels a little like a chicken-and-egg issue - the tutorial says that a subnet is set up before a blockchain can be spun up, but the subnet-cli documentation implies that the blockchain must be set up first.

    opened by mvadari 1
  • [DO NOT MERGE] *: use

    [DO NOT MERGE] *: use "avalanchego/wallet" for soft key, and others

    Found some weird behavior in our avalanchego wallet code (where GetTx fails if the subnet TX is not found in the cache, e.g., run add subnet and add subnet-validator separately... existing internal/wallet library works)

    DO NOT MERGE 
    opened by gyuho 0
  • Migrate to Encrypted Keys

    Migrate to Encrypted Keys

    Decode keys exported by the wallet:

    {"version":"6.0","salt":"4VuAVA3hxZuJjxJdbZTghmJxWVDv","activeIndex":0,"keys":[{"key":"4KEe2rojfbxjTSqcKfW4ekvSmgtabKHDhz18XMP4yiAheriarunz5aSoqTqUD95hgPZKLYkqehLZUVxhxBTpj8Yrhf9rmbN3WhvQVdZmwCncbRC7EWY7avUBtGwhv5m3tUpdfh44cTH84Y1N5Szsy6Bf2STSd3HJHbbxFMvz2YLT7F2kYFyNGFgLRARFPSbeafSGqCUAPLtG84vPtsPTFu8SCxxZ61ohby","iv":"UgEUtg4Z3oy3HyteFCxhgt","type":"mnemonic"}]}
    

    Wallet Code: https://github.com/ava-labs/avalanche-wallet-sdk/blob/a9337c388972e912d92fc29e76bd9f930cda2f41/src/Keystore/Crypto.ts#L113-L194

    enhancement 
    opened by patrick-ogrady 0
  • Add Pre-Configured Launch Options

    Add Pre-Configured Launch Options

    In an ideal world, the subnet-cli makes it effortless to deploy some "known" VMs like subnet-evm" with only a custom genesis file. Stretch goal would be also downloading the latest binary and moving it intoavalanchego`'s plugin directory.

    enhancement 
    opened by patrick-ogrady 0
Releases(v0.0.2)
Owner
Ava Labs
Ava Labs
Package command provide simple API to create modern command-line interface

Package command Package command provide simple API to create modern command-line interface, mainly for lightweight usage, inspired by cobra Usage pack

chenen 0 Jan 16, 2022
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

Kaleido 1 Mar 1, 2022
FireFly Command Line Interface (CLI)

FireFly CLI The FireFly CLI can be used to create a local FireFly stacks for offline development of blockchain apps. This allows developers to rapidly

null 38 Aug 5, 2022
An unofficial command line interface (CLI) for ASPEN's Oneliner application

Overview OlxCLI is an unofficial command line interface (CLI) for ASPEN's Oneliner application. The CLI provides commands for running common fault sim

Isaac 0 Jan 3, 2022
Free5GC Network Function (NF) Command Line Interface (CLI)

NFCLI free5GC Network Function (NF) Command Line Interface (CLI) based on Thrift Thrift Installation Steps Donwload Thrift 0.15.0 ./bootstrap.sh ./con

Muthuraman Elangovan 0 Jan 11, 2022
bluemonday-cli is a simple command-line interface to bluemonday

bluemonday-cli bluemonday-cli is a simple command-line interface to bluemonday. We've configured bluemonday for ROVR's specific requirements. It reads

ROVR Labs 0 Jan 24, 2022
An open-source GitLab command line tool bringing GitLab's cool features to your command line

GLab is an open source GitLab CLI tool bringing GitLab to your terminal next to where you are already working with git and your code without switching

Clement Sam 2k Aug 9, 2022
A command line tool that builds and (re)starts your web application everytime you save a Go or template fileA command line tool that builds and (re)starts your web application everytime you save a Go or template file

# Fresh Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file. If the web framework yo

null 0 Nov 22, 2021
A command line tool to prompt for a value to be included in another command line.

readval is a command line tool which is designed for one specific purpose—to prompt for a value to be included in another command line. readval prints

Venky 0 Dec 22, 2021
Manage your gists from the command-line.

Gister Manage your gists from the command-line. You can even manage your gists using your favorite editor. Demo Create a github access token https://h

Dutchcoders 58 Apr 8, 2022
Easily manage your work via command line

Wo Easily manage your work via command line Introduction Wo, is cli that provides it easy to manage your workspace. Wo provides to manipulating workfl

Ali Furkan 5 Dec 11, 2021
An interactive command-line tool to manage your environments

goto An interactive command-line tool to manage your environments Overview You always need to login to some Linux machine or connect to a MySQL instan

Lucien 10 Jul 11, 2022
This is a command line application to manage and fine-tune Time Machine exclude paths.

heptapod This is a command line application to manage and fine-tune Time Machine exclude paths. This repository is a WIP! The advertised functionality

Gergő Törcsvári 12 Jul 25, 2022
A Go library and a command-line tool to manage Docker Swarm clusters

go-swarm go-swarm is a Go library and command-line tool for managing the creation and maintenance of Docker Swarm cluster. Features: Creates new Swarm

AUCloud 3 Jul 26, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 622 Aug 7, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Maxar Infrastructure 1 Feb 5, 2022
Command Line Interface for Terraform Enterprise/Cloud ( tecli )

In a world where everything is Terraform, teams use Terraform Cloud API to manage their workloads. TECLI increases teams productivity by facilitating such interaction and by providing easy commands that can be executed on a terminal or on CI/CD systems.

Amazon Web Services - Labs 200 Jun 30, 2022
a command line interface to orbit.love

orbit-cli NAME: orbit-cli - a command line interface to orbit.love USAGE: orbit-cli [global options] command [command options] [arguments...]

Geoffrey Huntley 4 May 18, 2021
Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go.

What is Lux? Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go. Lux provides it's users with the abilit

BanDev 42 Jul 27, 2022