> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Helius CLI

> 功能齐全的Helius命令行界面。95多个命令用于账户管理、区块链查询、交易发送、webhooks、流媒体、质押等。专为代理和自动化设计。

[Helius CLI](https://www.npmjs.com/package/helius-cli) 是Helius平台的全功能命令行界面。它提供95多个命令用于账户管理、区块链数据查询、交易发送、webhooks、实时流媒体、质押、ZK压缩等，每个命令都有机器可读的JSON输出。

<Tip>
  **使用MCP兼容AI工具？** [Helius MCP服务器](/zh/agents/mcp) 是推荐的AI代理与Helius交互的方式——它提供10个具有结构化输入/输出的路由工具，包括内置的账户注册。使用CLI用于shell脚本、CI/CD管道，或在MCP不可用时。
</Tip>

## 安装

```bash theme={"system"}
npm install -g helius-cli
```

## 快速开始 — 已有用户

如果你已经有Helius API密钥，只需设置并开始：

```bash theme={"system"}
helius config set-api-key YOUR_API_KEY
```

从[dashboard.helius.dev](https://dashboard.helius.dev)获取你的密钥。就是这样 —— 跳过下面的注册步骤。

## 快速开始 — 新用户

<Note>
  所有 `helius signup` 调用都需要 `--email`、`--first-name` 和 `--last-name` — 包括 Agent 计划。
</Note>

<Steps>
  <Step title="生成密钥对">
    ```bash theme={"system"}
    helius keygen
    ```

    输出：

    ```
    ✓ Keypair generated
    Path: ~/.helius/keypair.json
    Address: 7xKp...3nQm

    To use this wallet, fund it with:
      • ~0.001 SOL for transaction fees
      • 1 USDC for Helius signup
    ```

    以上资助提示仅适用于使用自动支付的情况 —— 如果计划通过托管链接支付，请跳过资助。
  </Step>

  <Step title="创建账户">
    两种支付模式：托管链接（从任何钱包支付，无需资助）或自动支付（从本地密钥对支付 USDC，必须持有约 0.001 SOL 加上计划金额）。

    ```bash theme={"system"}
    # Default: print a hosted payment link, pay with any wallet in the browser
    helius signup --email you@example.com --first-name Jane --last-name Doe

    # After paying via link, finalize the account
    helius signup --resume

    # Or autopay from the local keypair
    helius signup --plan agent --pay --email you@example.com --first-name Jane --last-name Doe
    ```
  </Step>

  <Step title="获取您的 API 密钥和端点">
    ```bash theme={"system"}
    helius projects
    helius apikeys <project-id>
    helius rpc <project-id>
    ```
  </Step>
</Steps>

<Warning>
  你的API密钥是敏感信息，授予对你Helius账户的访问权限。切勿在客户端代码、公共仓库或浏览器可访问区域中暴露它。
</Warning>

## 计划与定价

您可以直接通过 CLI 购买任何 Helius 共享计划。在注册时传递 `--plan`，或稍后使用 `helius upgrade`：

| 计划           | 价格       | 积分          | `--plan` 值     |
| ------------ | -------- | ----------- | -------------- |
| Agent        | 一次性 \$1  | 1,000,000   | `agent`        |
| Developer    | 每月 \$49  | 10,000,000  | `developer`    |
| Business     | 每月 \$499 | 100,000,000 | `business`     |
| Professional | 每月 \$999 | 200,000,000 | `professional` |

<Note>
  **Agent** 计划（`agent`）是默认的。它的费用是 \$1（以 USDC 支付）以防止滥用，并提供 1,000,000 积分。要获得更高的速率限制和更多积分，请注册付费计划或稍后升级。
</Note>

### 使用特定计划注册

```bash theme={"system"}
# Default: Agent plan ($1)
helius signup --email you@example.com --first-name Jane --last-name Doe

# Developer plan ($49/mo)
helius signup --plan developer --email you@example.com --first-name Jane --last-name Doe

# Yearly billing (paid plans only)
helius signup --plan business --period yearly --email you@example.com --first-name Jane --last-name Doe
```

### 升级现有账户

```bash theme={"system"}
helius upgrade --plan developer --email you@example.com --first-name Jane --last-name Doe
```

### 支付续订费用

当订阅续订到期（每月或每年）时，Helius 会创建一个 **支付意图**——带有唯一 ID、金额和过期的待定付款。您将通过电子邮件或[仪表板](https://dashboard.helius.dev)收到支付意图 ID。

```bash theme={"system"}
helius pay <payment-intent-id>
```

该命令获取意图详情，显示金额和过期时间，询问确认，然后从您的密钥对钱包发送 USDC 付款。

## 命令参考

CLI 提供了 95 个以上的命令，涵盖 14 个类别。每个命令都支持 `--json` 用于机器可读输出，以及 `--api-key <key>` / `--network <net>` 全局覆盖。

<Card title="完整命令参考" icon="terminal" href="/zh/agents/cli/commands">
  所有 95 个以上的命令——账户管理、区块链查询、DAS API、钱包、webhooks、交易发送、WebSockets、staking、ZK 压缩等
</Card>

## JSON 输出模式

将 `--json` 添加到任何命令以获得机器可读输出：

```bash theme={"system"}
helius projects --json
helius balance Gh9ZwEm... --json
helius asset owner 86xCnPe... --json
```

示例：

```json theme={"system"}
{
  "projects": [
    {
      "id": "67b9d260-726b-4ba3-8bb0-dbbf794641bf",
      "name": "My Project",
      "plan": "free"
    }
  ]
}
```

## 退出代码

代理应检查退出代码以实现可靠自动化：

| 代码 | 含义      |
| -- | ------- |
| 0  | 成功      |
| 1  | 通用错误    |
| 10 | 未登录     |
| 11 | 没有找到密钥对 |
| 20 | SOL 不足  |
| 21 | USDC 不足 |
| 30 | 找不到项目   |
| 31 | 项目未找到   |
| 40 | API 错误  |

## 配置

配置存储在 `~/.helius/`：

```
~/.helius/
├── config.json    # JWT token, API key, network, default project
└── keypair.json   # Solana keypair (if generated with keygen)
```

用以下方式管理配置：

```bash theme={"system"}
helius config show              # View current config
helius config set-api-key <key> # Set API key
helius config set-network devnet # Switch to devnet
helius config set-project <id>  # Set default project
helius config clear             # Reset everything
```

### API 密钥解析顺序

API 密钥按以下顺序解析：

1. `--api-key <key>` 标志（每命令覆盖）
2. `HELIUS_API_KEY` 环境变量
3. `~/.helius/config.json`（通过 `helius config set-api-key` 设置）

## 全局选项

所有命令接受这些标志：

| 标志                     | 描述                          |
| ---------------------- | --------------------------- |
| `--api-key <key>`      | 覆盖已配置的 API 密钥               |
| `--network <net>`      | 覆盖网络 (`mainnet` 或 `devnet`) |
| `--json`               | 以 JSON 格式输出                 |
| `-k, --keypair <path>` | 密钥对文件路径（需要签名的命令）            |

## 全代理工作流程

```bash theme={"system"}
# Step 1: Generate keypair
helius keygen

# Step 2: Create account (default: hosted payment link, pay from any wallet)
helius signup --email you@example.com --first-name Jane --last-name Doe
helius signup --resume   # Finalize after paying via link
# Or autopay from the local keypair (requires ~0.001 SOL + plan USDC):
# helius signup --plan agent --pay --email you@example.com --first-name Jane --last-name Doe

# Step 3: Get API keys
helius projects
helius apikeys <project-id>

# Step 4: Get RPC endpoints
helius rpc <project-id>

# Step 5: Start querying
helius balance <address>
helius asset owner <wallet-address>
helius tx history <address> --limit 10
```

## 下一步

<CardGroup cols={2}>
  <Card title="代理概述" icon="robot" href="/zh/agents/overview">
    代理的 API 指南、工作流程和错误处理
  </Card>

  <Card title="Helius MCP" icon="plug" href="/zh/agents/mcp">
    将 AI 工具直接连接到 Helius API
  </Card>

  <Card title="查看计划" icon="credit-card" href="/zh/billing/plans">
    了解 Helius 计划和升级选项
  </Card>

  <Card title="仪表板" icon="chart-line" href="https://dashboard.helius.dev">
    监控您的 API 使用情况和管理密钥
  </Card>
</CardGroup>

## 支持

<CardGroup cols={2}>
  <Card title="Discord 社区" icon="discord" href="https://discord.com/invite/6GXdee3gBj">
    加入我们的 Discord 以获取实时帮助和社区支持
  </Card>

  <Card title="电子邮件支持" icon="envelope" href="mailto:support@helius.xyz">
    直接联系我们的支持团队
  </Card>
</CardGroup>
