Skip to main content
The Bags CLI (@bagsfm/bags-cli) is a terminal tool that wraps the Bags API and SDK into simple commands. It lets you trade tokens, launch tokens, claim fees, manage fee share configs, and more all without writing code.

Requirements

  • Node.js 18 or later
Verify your Node version:
node --version

Installation

Install globally via npm:
npm install -g @bagsfm/bags-cli
Or run directly without installing:
npx @bagsfm/bags-cli --help
After installing globally, the bags binary is available in your terminal:
bags --help

Quick Start with bags setup

The fastest way to get going is the first-run wizard. It configures your RPC endpoint, imports your wallet, and authenticates in a single command:
bags setup
The wizard prompts you for:
  1. Solana RPC URL — defaults to https://api.mainnet-beta.solana.com if left blank
  2. Private key — accepts a base58-encoded key or a JSON integer array
  3. MFA code — if your account has MFA enabled
You can also pass everything as flags for non-interactive use:
bags setup \
  --rpc-url https://your-rpc-provider.com \
  --private-key YOUR_BASE58_PRIVATE_KEY \
  --key-name "My CLI Key"
FlagDescriptionDefault
--rpc-url <url>Solana RPC endpointhttps://api.mainnet-beta.solana.com
--private-key <key>Base58 private key or JSON integer arrayPrompted interactively
--key-name <name>Label for the generated API keyBags CLI Key
Once setup completes, you’ll see a summary with your wallet address, masked API key, and RPC URL.

Manual Setup (Step by Step)

If you prefer to configure each piece individually:

1. Create or Import a Wallet

Generate a new Solana keypair:
bags wallet generate
Or import an existing key:
bags wallet import --key YOUR_BASE58_PRIVATE_KEY
The keypair is saved to ~/.config/bags/keypair.json.

2. Authenticate

Log in using the wallet signature flow. The CLI handles the challenge/sign/callback sequence automatically:
bags auth login
If your account has MFA enabled, you’ll be prompted for the code.
FlagDescriptionDefault
--keypair <path>Path to a custom keypair file~/.config/bags/keypair.json
--key-name <name>Label for the API keyBags CLI Key

3. Configure Settings

Set your preferred RPC endpoint and commitment level:
bags settings set --rpc-url https://your-rpc-provider.com --commitment confirmed

4. Verify

Check that everything is working:
bags auth status
bags wallet show

Configuration Files

All CLI state lives under ~/.config/bags/:
FilePurpose
keypair.jsonYour Solana keypair (secret key bytes). Permissions are set to 0600.
credentials.jsonAPI key, key ID, wallet address, and authentication timestamp. Permissions are set to 0600.
config.jsonCLI settings: RPC URL, commitment level, output mode.
Never share your keypair.json or credentials.json. These files contain secrets that grant full access to your wallet and API key.

Global Options

Every command supports these global flags:
FlagDescription
--jsonForce machine-readable JSON output regardless of settings
--input-json <json>Provide options as a JSON object, merged with any explicit flags
The --input-json flag is useful for scripting. Explicit CLI flags take precedence over values in the JSON object:
bags trade quote --input-json '{"inputMint":"So11...","outputMint":"EPjF...","amount":1000000}'

Output Modes

Control how the CLI formats its output:
bags settings set --output json
ModeDescription
prettyHuman-friendly colored output (default)
tableTabular format for list data
jsonRaw JSON for piping into other tools
View your current settings at any time:
bags settings show

Uninstalling

Remove credentials and keypair:
bags auth logout --all
Uninstall the package:
npm uninstall -g @bagsfm/bags-cli

Next Steps