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

# Gatekeeper (Beta)

> Helius 为 Solana 专门构建的高性能边缘网关

Gatekeeper 是 Helius 的新边缘网关，现在处于公开测试版，已从关键路径中移除 Cloudflare。消除我们的边缘延迟，释放我们核心 API 和服务的真正速度——响应时间改善范围从几十毫秒到数百毫秒不等。

Gatekeeper 作为所有请求的单一统一入口点（例如 JSON-RPC、WebSockets 和 Helius APIs）：在地理上分布的边缘位置终止连接，并智能地将请求路由到我们的后端基础设施。

对于延迟关键型工作负载，Gatekeeper 提供最短的网络路径，减少跳数并节省毫秒数。

## 快速入门

要使用 Gatekeeper，请将现有的端点替换为 Gatekeeper (Beta) 端点：

<CodeGroup>
  ```javascript Before theme={"system"}
  const url = "https://mainnet.helius-rpc.com?api-key=YOUR_API_KEY";
  ```

  ```javascript After theme={"system"}
  const url = "https://beta.helius-rpc.com?api-key=YOUR_API_KEY";
  ```
</CodeGroup>

**就是这样！**

您现有的 API 密钥无需任何额外更改即可使用。

## 支持的方法

Gatekeeper 目前支持：

* 所有标准的 Solana RPC 端点
* 所有特定于 Helius 的 RPC 端点（例如，gTFA）
* 所有 Helius WebSocket 端点（标准 Solana 方法加上 Helius 扩展，如 `transactionSubscribe`）
* 所有 DAS API 端点
* 所有 Photon API 端点（即 ZK 压缩）
* Helius 优先费用 API
* 增强交易 API

<Note>
  **当前不支持**：LaserStream 尚未在 Gatekeeper 上可用。继续使用专用的 [LaserStream 端点](/zh/laserstream/grpc#mainnet-endpoints) 进行 gRPC 连接。
</Note>

## 使用示例

<CodeGroup>
  ```javascript JavaScript/TypeScript theme={"system"}
  const url = `https://beta.helius-rpc.com?api-key=${YOUR_API_KEY}`;

  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: 1,
      method: 'getLatestBlockhash',
      params: []
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={"system"}
  import requests

  url = f"https://beta.helius-rpc.com?api-key={YOUR_API_KEY}"

  response = requests.post(url, json={
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLatestBlockhash",
      "params": []
  })

  print(response.json())
  ```

  ```rust Rust theme={"system"}
  use reqwest;
  use serde_json::json;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let url = format!("https://beta.helius-rpc.com?api-key={}", YOUR_API_KEY);

      let client = reqwest::Client::new();
      let response = client
          .post(&url)
          .json(&json!({
              "jsonrpc": "2.0",
              "id": 1,
              "method": "getLatestBlockhash",
              "params": []
          }))
          .send()
          .await?;

      let data = response.json::<serde_json::Value>().await?;
      println!("{:?}", data);

      Ok(())
  }
  ```

  ```bash cURL theme={"system"}
  curl https://beta.helius-rpc.com?api-key=YOUR_API_KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getLatestBlockhash",
      "params": []
    }'
  ```
</CodeGroup>

## WebSocket 支持

Gatekeeper 支持 Helius WebSockets——包括标准的 Solana 订阅方法和 Helius 扩展（`transactionSubscribe`，增强的 `accountSubscribe`）——具有相同的性能改进。

```javascript theme={"system"}
const ws = new WebSocket(`wss://beta.helius-rpc.com?api-key=${YOUR_API_KEY}`);

ws.on('open', () => {
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'transactionSubscribe',
    params: [
      {
        accountInclude: ['YOUR_ACCOUNT_ADDRESS']
      },
      {
        commitment: 'confirmed',
        encoding: 'jsonParsed',
        transactionDetails: 'full',
        showRewards: true,
        maxSupportedTransactionVersion: 0
      }
    ]
  }));
});

ws.on('message', (data) => {
  console.log('Transaction:', JSON.parse(data));
});
```

## 预期效果

在测试期间：

* **更低的延迟** - 显著加快的响应时间
* **更好的负载性能** - 在高流量期间提高的可靠性
* **更一致的响应时间** - 减少延迟的变化
* **改进的 WebSocket 稳定性** - 更可靠的实时连接
* **完全的 API 兼容性** - 所有现有的 RPC 方法都相同
* **相同的定价** - 测试访问无额外费用
* **全球分布** - 跨多个大陆的边缘节点

## 谁应该使用 Gatekeeper？

Gatekeeper 适合注重性能的应用程序：

* **高频应用** - 任何延迟重要的应用
* **交易机器人** - 最大速度以抓住套利机会
* **DeFi 协议** - 实时价格信息和快速交易提交
* **游戏应用** - 低响应时间以提供流畅 UX
* **NFT 市场** - 即时铸造和低延迟查询

## 迁移核对清单

<Steps>
  <Step title="更新您的端点">
    将代码中的 `mainnet.helius-rpc.com` 更改为 `beta.helius-rpc.com`
  </Step>

  <Step title="在开发环境中测试">
    运行您的测试套件以验证一切按预期工作
  </Step>

  <Step title="监控性能">
    检查您的指标，您应该看到改善的延迟和更一致的响应时间
  </Step>

  <Step title="部署到生产环境">
    一旦验证，通过生产环境部署您的更改
  </Step>
</Steps>

## 回滚

如果需要回滚，只需切换回标准端点：

```javascript theme={"system"}
const url = "https://mainnet.helius-rpc.com?api-key=YOUR_API_KEY";
```

## 限制与已知问题

<Warning>
  **测试状态**：Gatekeeper 已准备好生产，但仍在优化中。我们建议在将生产流量切换之前在开发环境中进行测试。
</Warning>

**尚不支持：**

* **LaserStream**：使用专用的 [LaserStream 端点](/zh/laserstream/grpc#mainnet-endpoints) 进行 gRPC 连接

**当前状态：**

* 一些高级功能仍在推出中
* 我们正在持续优化路由算法
* 性能改进正在进行中

## 推出计划

在我们优化性能和收集反馈时，Gatekeeper 目前为**选择加入**状态。

时间表：

* **现在**：所有用户可使用公开 beta
* **未来几周**：进一步优化和性能改进
* **未来几个月**：逐步将所有流量迁移到 Gatekeeper 作为默认

## 反馈与支持

我们正在积极监控 Gatekeeper 的性能，并希望收到您的反馈：

* **有问题或疑问？** 联系 [support@helius.dev](mailto:support@helius.dev)
* **加入我们的 Discord** 进行实时讨论：[https://discord.com/invite/6GXdee3gBj](https://discord.com/invite/6GXdee3gBj)
* **通过您的开发者控制台报告错误**

## 常见问题

<AccordionGroup>
  <Accordion title="我需要新的 API 密钥吗？">
    不需要。您现有的 API 密钥可无任何更改地与 Gatekeeper 一起使用。
  </Accordion>

  <Accordion title="Gatekeeper 会额外收费吗？">
    不会。Gatekeeper 不会额外收费。您现有的定价计划适用。
  </Accordion>

  <Accordion title="Gatekeeper 支持哪些端点？">
    所有 JSON-RPC 端点均得到全面支持，包括标准的 Solana RPC 方法、特定于 Helius 的 RPC 端点（如 gTFA）、DAS、Photon、优先费用 API 和增强交易 API。WebSockets——包括标准的 Solana 订阅方法和 Helius 扩展，如 `transactionSubscribe`——也得到支持。
  </Accordion>

  <Accordion title="Gatekeeper 尚不支持哪些端点？">
    LaserStream 尚未在 Gatekeeper 上可用。对于 gRPC 连接，使用专用的 [LaserStream 端点](/zh/laserstream/grpc#mainnet-endpoints)。
  </Accordion>

  <Accordion title="如果在使用 Gatekeeper 时遇到问题怎么办？">
    您可以通过切换回 `mainnet.helius-rpc.com` 轻松回滚。如需帮助，请联系 [support](https://www.helius.dev/docs/support)。
  </Accordion>

  <Accordion title="Gatekeeper 何时会成为默认？">
    我们计划在未来几个月内逐步推出。在对默认 Helius 端点进行任何更改之前，我们会通知所有用户。
  </Accordion>

  <Accordion title="我可以在 Solana Devnet 或 Testnet 上使用 Gatekeeper 吗？">
    不，Gatekeeper 目前仅在 Solana Mainnet 上可用。Solana Devnet 和 Testnet 的支持即将推出。
  </Accordion>
</AccordionGroup>

## 开始使用

<CardGroup cols={2}>
  <Card title="尝试 Gatekeeper" icon="rocket" href="https://www.helius.dev/docs/gatekeeper/migration-guide">
    在不到 5 分钟内迁移到 Gatekeeper
  </Card>

  <Card title="了解 Gatekeeper" icon="book" href="https://www.helius.dev/blog/introducing-gatekeeper">
    阅读我们的博客了解 Gatekeeper 如何工作
  </Card>
</CardGroup>
