> ## 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.

# Phantom技能

> 使用Phantom Connect SDK和Helius基础设施构建前端Solana应用。涵盖React、React Native和浏览器SDK集成、交易签名、令牌授权、NFT铸造、支付和安全前端架构。

**Phantom**技能使您的AI助手能够成为构建前端Solana应用的专家。它结合了[Phantom Connect SDK](https://phantom.com)——React、React Native和原生JS钱包集成——与Helius基础设施进行交易提交、费用优化、资产查询和实时更新。

安装后，AI会自动读取正确的参考文件并根据您的请求调用正确的[MCP工具](/zh/agents/mcp)，无需手动选择工具。

<Info>
  **Claude Code:** `/helius:phantom`（通过[plugin](/zh/agents/claude-code-plugin)）或自动调用（独立）。**Codex:** `$helius-phantom`（从`.agents/skills/`自动发现）。**API / Cursor / ChatGPT:** 使用预构建的[系统提示变体](/zh/agents/skills/overview#using-skills-across-platforms)。
</Info>

## 覆盖范围

Phantom技能可以让AI在Phantom SDK和Helius工具之间进行路由：

| 领域                      | 参考文件                                             | 使用的MCP工具                                                    |
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------------- |
| **钱包连接 — React**        | `react-sdk.md`                                   | —                                                           |
| **钱包连接 — 浏览器**          | `browser-sdk.md`                                 | —                                                           |
| **钱包连接 — React Native** | `react-native-sdk.md`                            | —                                                           |
| **交易**                  | `transactions.md`, `helius-sender.md`            | `getPriorityFeeEstimate`, `getSenderInfo`                   |
| **令牌授权**                | `token-gating.md`, `helius-das.md`               | `getAssetsByOwner`, `searchAssets`, `getAsset`              |
| **NFT铸造**               | `nft-minting.md`, `helius-sender.md`             | `getAsset`, `getPriorityFeeEstimate`                        |
| **加密支付**                | `payments.md`, `helius-enhanced-transactions.md` | `parseTransactions`, `getPriorityFeeEstimate`               |
| **前端安全**                | `frontend-security.md`                           | —                                                           |
| **投资组合显示**              | `helius-das.md`, `helius-wallet-api.md`          | `getAssetsByOwner`, `getWalletBalances`, `getTokenBalances` |
| **实时更新**                | `helius-websockets.md`                           | `transactionSubscribe`, `accountSubscribe`                  |
| **交易历史**                | `helius-enhanced-transactions.md`                | `parseTransactions`, `getTransactionHistory`                |
| **集成模式**                | `integration-patterns.md`                        | 多个（取决于模式）                                                   |

## 关键规则

Phantom 技能强制执行关键模式，以防止常见的前端错误：

* **始终使用 `@phantom/react-sdk`** 用于 React（绝不要使用 `window.phantom.solana` 或 `@solana/wallet-adapter-react`）
* **始终使用 `@phantom/browser-sdk`** 用于 vanilla JS 和 **`@phantom/react-native-sdk`** 用于 React Native
* **绝不要在客户端代码中暴露 Helius API 密钥** — 只有 `https://sender.helius-rpc.com/fast` 是无需 API 密钥而浏览器安全的
* **通过后端代理其他所有内容** — 绝不要直接从浏览器打开 Helius WebSockets
* **始终通过 Helius Sender 提交交易** 使用 `skipPreflight: true`，`maxRetries: 0` 和 Jito 提示
* **使用 `getPriorityFeeEstimate`** MCP 工具 — 绝不要硬编码优先费用

## 组合模式

该技能为复杂应用程序提供了五种端到端参考模式：

1. **交换 UI** — 聚合器 → Phantom 签名 → Helius Sender 提交
2. **投资组合查看器** — Phantom 连接 → 后端代理 → DAS/钱包 API
3. **实时仪表板** — Phantom 连接 → 服务器 WebSocket → 客户端中继
4. **代币转账** — 构建 VersionedTransaction → Phantom 签名 → Sender 提交
5. **NFT 画廊** — Phantom 钱包 → 后端 DAS 查询 → 显示 NFTs

## 先决条件

该技能需要 [Helius MCP 服务器](/zh/agents/mcp)。对于嵌入式钱包（Google/Apple 登录），您还需要 [Phantom Portal](https://phantom.com/portal) 帐户，并允许列入白名单的重定向 URL。

如果通过 [Claude Code 插件](/zh/agents/claude-code-plugin) 安装，MCP 服务器会自动启动。对于独立安装，请手动添加：

```bash theme={"system"}
claude mcp add helius npx helius-mcp@latest
```

## 独立安装

如果您想要不带完整插件的 Phantom 技能，请直接安装：

<Steps>
  <Step title="克隆仓库">
    ```bash theme={"system"}
    git clone https://github.com/helius-labs/core-ai.git
    cd core-ai/helius-skills/helius-phantom
    ```
  </Step>

  <Step title="运行安装脚本">
    ```bash theme={"system"}
    ./install.sh
    ```

    这将技能及其引用文件安装到 `~/.claude/skills/helius-phantom/`。

    **选项：**

    * `./install.sh --project` — 安装到当前项目 (`.claude/skills/helius-phantom/`)
    * `./install.sh --path /custom/path` — 安装到自定义目录
  </Step>

  <Step title="安装Helius MCP服务器">
    ```bash theme={"system"}
    claude mcp add helius npx helius-mcp@latest
    ```
  </Step>

  <Step title="设置你的API密钥">
    ```bash theme={"system"}
    export HELIUS_API_KEY=YOUR_API_KEY
    ```

    或使用Claude Code内的`setHeliusApiKey` MCP工具。如果需要新账户，请参阅[Helius CLI](/zh/agents/cli)或通过[MCP工具](/zh/agents/mcp)使用自主注册流程。
  </Step>
</Steps>

## 示例提示

安装后，用简单的英语询问：

* "使用Phantom钱包构建交换UI"
* "构建连接Phantom后显示令牌的投资组合查看器"
* "如何在Next.js中代理我的Helius API密钥？"
* "构建具有钱包连接的实时仪表板"
* "使用Phantom向我的React应用程序添加令牌门控"
* "使用Phantom和Metaplex Core构建NFT铸造页面"

AI会自动选择合适的工具并阅读合适的参考文件。

## 包含内容

该技能安装了两个组件：

* **`SKILL.md`** — 指导AI行为的路由逻辑、规则和专家上下文
* **`prompts/`** — 预构建的系统提示变体 (`openai.developer.md`, `claude.system.md`, `full.md`) — 参阅[平台设置](/zh/agents/skills/overview#using-skills-across-platforms)
* **`references/`** — 16个深入文档文件：
  * `react-sdk.md` — Phantom React SDK (`@phantom/react-sdk`)
  * `browser-sdk.md` — Phantom浏览器SDK (`@phantom/browser-sdk`)
  * `react-native-sdk.md` — Phantom React Native SDK (`@phantom/react-native-sdk`)
  * `transactions.md` — 交易签名模式
  * `token-gating.md` — 令牌门控访问控制
  * `nft-minting.md` — 使用Phantom进行NFT铸造
  * `payments.md` — 加密支付流程
  * `frontend-security.md` — API密钥代理和CORS
  * `integration-patterns.md` — 端到端复合模式
  * `helius-das.md` — DAS API参考
  * `helius-sender.md` — 发送者参考
  * `helius-priority-fees.md` — 优先费参考
  * `helius-wallet-api.md` — 钱包API参考
  * `helius-websockets.md` — WebSocket参考
  * `helius-enhanced-transactions.md` — 增强交易参考
  * `helius-onboarding.md` — 账户设置参考

## 了解更多

<CardGroup cols={2}>
  <Card title="Helius MCP" icon="plug" href="/zh/agents/mcp">
    支持此技能工具的MCP服务器
  </Card>

  <Card title="Claude Code Plugin" icon="puzzle-piece" href="/zh/agents/claude-code-plugin">
    一键安装MCP和技能
  </Card>

  <Card title="Build Skill" icon="hammer" href="/zh/agents/skills/build">
    使用Helius进行Solana一般开发
  </Card>

  <Card title="GitHub" icon="github" href="https://github.com/helius-labs/core-ai">
    源代码和问题跟踪
  </Card>
</CardGroup>
