Command-line tooling
The command-line tooling provides executable entrypoints for common Solana SDK actions. It turns shell arguments and configuration into RPC reads, wallet operations, and transaction-oriented commands while keeping the SDK as the layer that talks to Solana and handles key data.
Command interface
The command interface is a command tree built around the slnc executable. The executable supplies a version value and starts the root command, which then dispatches work to command groups and their subcommands.
Command tree
The root command groups operations by purpose instead of exposing one flat list of actions. The main groups cover cluster reads, native SOL operations, token operations, token registry work, and encrypted wallet management. The slnc command application describes these groups and their individual commands.
| Command family | Role |
|---|---|
get | Read information from a Solana cluster. |
system | Group native SOL instruction operations. |
token | Group token instruction operations. |
token-registry | Read and register token metadata. |
vault | Create, update, inspect, and export encrypted key material. |
References: cmd/…/main.go• L15-29 cmd/…/root.go• L30-47 cmd/…/get.go• L19-25 cmd/…/system.go• L22-29 cmd/…/token.go• L22-29 cmd/…/vault.go• L24-31
Request context
Shared command settings define where requests go and how the SDK reaches the endpoint. The default endpoint is the Solana mainnet endpoint, while short cluster names resolve to the devnet, testnet, or mainnet endpoint; a full URL is also accepted.
HTTP headers can be added to RPC requests. This supports providers that require an API key or another request header without changing the SDK call made by a command.
The following diagram shows how shell input becomes an SDK operation.
flowchart LR
A[Shell command] --> B[Command tree]
B --> C[Flags and positional arguments]
C --> D[Shared RPC client]
C --> E[Optional vault]
D --> F[Solana SDK]
E --> F
F --> G[Cluster result or transaction result]
References: cmd/…/root.go• L33-70 cmd/…/common.go• L28-59
Configuration names
The command layer accepts flags and maps them into an environment namespace with the SLNC_ prefix. Hyphens become underscores, and command scope is included in the name. Shared settings therefore have names such as SLNC_GLOBAL_RPC_URL and SLNC_GLOBAL_VAULT_FILE.
This gives scripts a way to provide stable settings without placing every value on the command line. Command-specific flags remain part of the command that owns them, while shared settings apply across the command tree.
References: cmd/…/root.go• L50-91 cmd/…/common.go• L61-65
Arguments and credentials
Command inputs have two different roles. Public request data can be passed as arguments or flags, while private key material is kept in an encrypted vault or entered through a hidden prompt.
Argument contracts
Each subcommand defines the shape of its positional input before it runs. For example, the native SOL and token transfer commands require a source, a destination, and an amount. Cobra rejects calls that do not meet the required count before the handler processes them.
The command layer is responsible for collecting these values. The SDK remains responsible for interpreting Solana addresses, building protocol data, signing transactions, and sending requests when the command supports that operation.
References: cmd/…/system_transfer.go• L27-46 cmd/…/token_transfer.go• L27-45
Vault-backed credentials
The vault is the command tool's shared source of private keys for operations that need signing. A vault file stores encrypted key material and metadata; a command opens it before it can use the keys as a signing provider.
Vault creation can generate new keypairs or import private keys. Later commands can add keys or list the public keys that the vault contains. The vault file is written with restrictive local file permissions, and the command flow reports public keys rather than exposing private keys during normal creation and update work.
References: cmd/…/common.go• L71-97 cmd/…/vault_create.go• L32-51 cmd/…/vault_add.go• L32-79 vault/vault.go• L24-35 vault/vault.go• L87-125
Secret entry paths
Passphrase-protected vaults prompt on the terminal without showing the typed value. The shared password reader prints a prompt, reads the password from standard input without echoing it, and then moves to a new line. Creation asks for confirmation, while opening an existing vault asks for the decryption passphrase.
Automation can provide SLNC_GLOBAL_INSECURE_VAULT_PASSPHRASE, but the name signals that this path places the secret in an environment value. A second vault mode uses Google Cloud KMS and requires a KMS key path plus the credentials needed by the Google client. The selected mode must match the vault metadata.
References: cli/getpass.go• L15-29 cli/cli.go• L23-48 vault/secretboxer.go• L25-53 cmd/…/vault_create.go• L105-129 vault/kmsgcp.go• L35-77
SDK entrypoints
The command application is a thin boundary around the SDK. It supplies user-facing input and shared context, then relies on SDK clients and data types for Solana-specific work.
Read operations
Read commands create a configured RPC client and use the command arguments to request cluster data. Their output is intended for a person or a shell script that needs account, block, slot, transaction, or token information.
References: cmd/…/get.go• L19-25 cmd/…/common.go• L28-46 cmd/…/get_balance.go• L28-52 cmd/…/get_transactions.go• L35-80
Transaction operations
Transaction commands are the place where command input is intended to become SDK instructions and signed submissions. The command tree reserves this role for native SOL, token, and token registry actions, with the vault supplying keys when signing needs them.
The current native SOL and token transfer handlers only set up the RPC client, capture the three positional values, print them, and return. They do not yet build or submit a transfer. Engineers should treat these commands as entrypoint scaffolding until their handlers connect the full SDK transaction flow.
References: cmd/…/system_transfer.go• L27-50 cmd/…/token_transfer.go• L27-49 cmd/…/token_registry_register.go• L35-163
Error outcomes
The root command prints a command error and exits with status 1 when dispatch returns an error. Shared setup also stops early for invalid headers, missing vault files, unsupported vault modes, failed decryption, or an unusable RPC endpoint.
This behavior makes setup errors visible before a command reaches the cluster. It also means scripts should treat a non-zero process status as a failed operation rather than relying only on printed output.
References: cmd/…/root.go• L42-47 cmd/…/common.go• L37-69 cmd/…/common.go• L77-97 vault/secretboxer.go• L31-53
Related documentation
Read slnc command application for the command tree, command-specific behavior, and the detailed lifecycle of the executable.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the root flag names aligned with their
SLNC_environment names. The environment mapping is used by scripts and deployment settings. - Keep vault metadata and secret-box selection aligned. A vault written with one wrapping mode cannot be opened through a different credential path.
- Keep RPC URL aliases and the shared client setup aligned. A new cluster alias must resolve before command handlers create their client.
- When a transaction command becomes active, connect its argument contract to vault key selection, transaction signing, and RPC submission as one flow.
- Preserve non-zero process status for setup and request errors so shell callers can detect failure.
- Keep hidden terminal input intact when changing password prompts. A prompt must not echo the passphrase to the terminal.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A command uses an invalid HTTP header format. | The shared client setup stops before an RPC request is sent. | Use Name: value header entries without spaces in the header name. |
| The configured vault file is missing or cannot be opened. | A signing-capable command exits before it can use a key. | Point --vault-file or SLNC_GLOBAL_VAULT_FILE to an existing vault. |
| A passphrase is wrong or a KMS key path is unavailable. | Vault decryption fails and private keys are not loaded. | Use the vault's matching secret source and valid KMS access. |
| A passphrase is entered through an unavailable or unsuitable terminal input. | Password capture can fail or behave differently from an interactive hidden prompt. | Use a terminal for interactive entry or the explicit automation path. |
| A transfer command is called with the wrong number of positional values. | Cobra rejects the command before its handler runs. | Provide from, to, and amount. |
| A native SOL or token transfer is invoked expecting a submission. | The current handler only prints the captured values and returns. | Use the SDK directly or wait for the command handler to implement transaction construction and submission. |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows the executable entrypoint and version handoff. |
| cmd/…/root.go | Defines the root command, shared flags, and environment mapping. |
| cmd/…/common.go | Shows shared RPC client setup, URL handling, error behavior, and vault loading. |
| cmd/…/get.go | Introduces the read-command family. |
| cmd/…/system_transfer.go | Shows the native SOL transfer argument boundary and current execution scope. |
| cmd/…/token_transfer.go | Shows the equivalent token transfer boundary. |
| cmd/…/vault_create.go | Shows how users create or import protected key material. |
| cmd/…/vault_add.go | Shows hidden private-key entry and vault update flow. |
| cli/getpass.go | Provides the terminal password reader used by vault credential prompts. |
| cli/cli.go | Defines passphrase collection and confirmation for vault operations. |
| vault/vault.go | Defines the encrypted vault's role as a key source for signing. |
| vault/secretboxer.go | Selects the passphrase or Google Cloud KMS credential path. |