sbv2-solana/website/api/cli/overview.mdx

80 lines
2.9 KiB
Plaintext

---
sidebar_position: 1
slug: /cli
title: Overview
---
# sbv2
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/switchboard-xyz/switchboard-v2/tree/main/cli) [![npm](https://img.shields.io/npm/v/@switchboard-xyz/switchboardv2-cli)](https://www.npmjs.com/package/@switchboard-xyz/switchboardv2-cli) ![Page Last Updated](./page-last-updated.svg)
The Switchboard V2 CLI provides an easy to use interface to setup and manage Switchboard onchain accounts.
## Install
Run the following command:
```bash npm2yarn
npm install -g @switchboard-xyz/switchboardv2-cli
```
## Overview
**Keypairs** The Switchboard V2 CLI lets you specify a keypair from an absolute or relative filesystem path as well as a Google Secret Manager secret. The following flags are common among most commands, with the exception of the print commands that require no keypairs:
- `--authority` is the keypair that is or will be the authority for a given account. The authority is responsible for authorizing new permissions, changing an account, or withdrawing from a token account.
- `--keypair` is required for any command that submits an onchain transaction such as creating accounts, turning the crank, or updating an account config. This keypair will default as the authority if the authority flag is not provided.
**Token Amounts**
Any commands that specify a token amount will be converted to the raw token amount if it contains a decimal. For example, wSOL has 9 decimal places so a CLI arguement of 1.5 would be interpretted as 1_500_000_000 tokens whereas 1 would be interpretted as 1 token.
**Logging** Most commands will have a `--silent`, `-s` flag that will suppress console output and only output a new account public key to assist in scripting. A `--verbose`, `-v` flag will do the opposite and log any debug or configuration information to help debug.
**Help** All commands can be run with the `--help` flag to print the available arguments and flags for a given command.
## Examples
### Print
```bash
# check account discriminator and print account information if found
sbv2 print PUBLICKEY
# print an oracle account by its public key
sbv2 print:oracle ORACLEKEY
# print an aggregator account and save to a JSON file
sbv2 print:aggregator AGGREGATORKEY --outputFile outputFile.json
```
### Create a Queue
```bash
sbv2 queue:create \
--keypair payer-keypair.json \
-f queue-schema.json \
-n "My New Queue" \
--numOracles 1 \
-v
```
### Create Aggregator
```bash
# write sample json files to outputDirectory
sbv2 print:json:samples outputDirectory
# create aggregator from json
sbv2 aggregator:create:json aggregator.json \
--keypair ../dev/switchboardxyz/payer-keypair.json \
--queueKey GhYg3R1V6DmJbwuc57qZeoYG6gUuvCotUF1zU3WCj98U \
--outputFile aggregator.schema.json
```
<!-- ### Create Oracle
### Create Queue
#### Permit an Aggregator
### Create Queue from JSON
#### Adding Aggregators -->