# Solana CLI: the Carbium command line

## Command line

Carbium from your terminal: every RPC and DAS method by name, quotes and unsigned swaps, live tails, usage, keys and webhooks.

`carbium` is the command line for the Carbium services. It calls RPC and DAS methods by name, gets quotes and builds unsigned swaps, tails WebSocket and Carbon Stream, and reads usage, keys, webhooks, DCA and tokens. It runs on Node 22.12 or later, or on Bun, and it never signs or sends a transaction.

### Install

The npm package is `carbium` and it installs the `carbium` command. It needs Node 22.12 or later, or Bun.

```
npm install -g carbium
carbium --help
```

### Install script

On Linux and macOS without Node, the script installs a standalone binary to `~/.carbium/bin` without sudo. The binary is checked against its release's `SHA256SUMS` before it is installed. `CARBIUM_VERSION` pins a version.

```
curl --proto '=https' --tlsv1.2 -fsSL https://carbium.sh/install.sh | sh
```

### Homebrew

```
brew install carbium-sh/tap/carbium
```

### Scoop

```
scoop bucket add carbium https://github.com/carbium-sh/scoop-bucket
scoop install carbium/carbium
```

### GitHub Actions

The action installs the command line on the runner and puts it on the path for the steps after it.

```
on: workflow_dispatch
jobs:
  carbium:
    runs-on: ubuntu-latest
    steps:
      - uses: carbium-sh/setup-carbium@v1
      - run: carbium --version
```

### Standalone binaries

The standalone binaries have no Carbon Stream commands: `carbium stream` needs the npm package. Each release lists the binaries for Linux, macOS and Windows with their checksums.

```
carbium --version
carbium stream slot   # in a standalone binary this says it needs the npm package
```

### Sign in

You can sign in three ways: with a 6-digit code sent by email, with an account key pasted at a hidden prompt, or with a message signed by your own wallet. For the wallet way, the CLI checks the signature you paste and never makes one. With `--email` or `--wallet`, login makes a read-only account key and stores it with your first service key. With `--key` it stores the account key you paste and no service key. The file is `~/.config/carbium/credentials.json` with mode 600 (`%APPDATA%\carbium` on Windows). Writes stay off until you run `carbium login --full` or `carbium config set writes true`, or pass `--allow-writes` for one run.

```
carbium login --email you@example.com
carbium login --key
carbium login --wallet 5tzFkiKscXHK5ZXCGbXZxdw7gTjjD1mBwuoFbhUvuAi9
carbium whoami
```

### First calls

Commands take the service key from `CARBIUM_KEY`, from `--key-file` or from the stored profile. A key typed on the command line is refused. `carbium test` calls getHealth and getLatestBlockhash. `rpc` takes a method name and JSON params, and `das` takes `key=value` pairs. `carbium rpc list` and `carbium das list` show the methods that are served.

```
carbium test
carbium rpc getSlot
carbium das getAssetsByOwner ownerAddress=DFFiJgCASVfPEQgRkrjkYAPGtFyo2pygx9aGp5XpMT9H limit=10
```

### Quote and unsigned swap

`carbium quote` takes the source mint, the destination mint and an amount in the source mint's base units. `carbium swap build` takes the quote's `quoteId` and your wallet's public key. It returns one unsigned transaction as base64, and your own wallet signs and sends it. `--out` also writes the transaction to a new file.

```
carbium quote So11111111111111111111111111111111111111112 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v 100000000
# put the quoteId from the answer above in place of <quoteId>
carbium swap build <quoteId> 5tzFkiKscXHK5ZXCGbXZxdw7gTjjD1mBwuoFbhUvuAi9 --out swap.txt
```

### Tails

A tail prints one JSON line per update on stdout. It stops after `--count` updates or at Ctrl-C. `stream tail` reads Carbon Stream, which needs a plan that includes it and the Yellowstone client installed next to the CLI, on Linux x64 or macOS. The stream client uses the system's CA certificates, so a slim container image needs the `ca-certificates` package or `SSL_CERT_FILE` set to a CA bundle.

```
carbium ws tail slot --count 3
npm install -g @triton-one/yellowstone-grpc
carbium stream tail --slots --count 3
```

### Account

These commands use the account key that `carbium login` stored, or `CARBIUM_ACCOUNT_KEY`. Key lists show a key's prefix and never its value.

```
carbium usage
carbium balance
carbium keys list
carbium webhooks list
```

### Output and exit codes

`--json` prints the service's answer as JSON. Without it, the answer prints as plain text. Data goes to stdout, while status lines and errors go to stderr, and `-q` turns off the status lines. The exit codes are:

- 0 ok
- 1 service error
- 2 usage
- 3 no key or refused
- 4 credits or rate limit
- 5 confirmation needed
- 130 interrupted

```
carbium --json rpc getSlot
carbium rpc getBalance 5tzFkiKscXHK5ZXCGbXZxdw7gTjjD1mBwuoFbhUvuAi9 '{"commitment":"confirmed"}' --json > balance.json
echo "exit $?"
```

### Completion

`carbium completion` prints a completion script for bash, zsh or fish. Use the line for your shell only.

```
eval "$(carbium completion bash)" # bash: in ~/.bashrc
autoload -Uz compinit && compinit; eval "$(carbium completion zsh)" # zsh: in ~/.zshrc
mkdir -p ~/.config/fish/completions && carbium completion fish > ~/.config/fish/completions/carbium.fish # fish: run once
```

[carbium on npm](https://www.npmjs.com/package/carbium) · [Source on GitHub](https://github.com/carbium-sh/carbium-js/tree/main/packages/cli) · [Releases and standalone binaries](https://github.com/carbium-sh/carbium-js/releases)
