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

# Cách di chuyển sang Gatekeeper

> Hướng dẫn từng bước để di chuyển ứng dụng của bạn sang Gatekeeper

Việc di chuyển sang Gatekeeper mất **chưa đến 5 phút**. Bạn chỉ cần thay đổi URL—khóa API vẫn hoạt động mà không cần sửa đổi gì.

## Di chuyển nhanh

Chỉ cần thay thế điểm cuối hiện tại:

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

**Vậy là xong!**

Kiểm thử ứng dụng, theo dõi hiệu suất và triển khai khi đã sẵn sàng.

## Ví dụ dành riêng cho từng framework

<Tabs>
  <Tab title="Solana Web3.js">
    ```javascript theme={"system"}
    import { Connection } from '@solana/web3.js';

    const connection = new Connection(
      `https://beta.helius-rpc.com/?api-key=${YOUR_API_KEY}`,
      'confirmed'
    );
    ```
  </Tab>

  <Tab title="Anchor">
    ```javascript theme={"system"}
    import { AnchorProvider } from '@coral-xyz/anchor';
    import { Connection } from '@solana/web3.js';

    const connection = new Connection(
      `https://beta.helius-rpc.com/?api-key=${YOUR_API_KEY}`,
      'confirmed'
    );

    const provider = new AnchorProvider(connection, wallet, {
      commitment: 'confirmed'
    });
    ```
  </Tab>

  <Tab title="Solana-py">
    ```python theme={"system"}
    from solana.rpc.api import Client

    rpc_url = f"https://beta.helius-rpc.com/?api-key={YOUR_API_KEY}"
    client = Client(rpc_url)
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={"system"}
    use solana_client::rpc_client::RpcClient;

    let rpc_url = format!("https://beta.helius-rpc.com/?api-key={}", YOUR_API_KEY);
    let client = RpcClient::new(rpc_url);
    ```
  </Tab>

  <Tab title="Environment Variable">
    ```bash theme={"system"}
    # .env file
    HELIUS_RPC_URL=https://beta.helius-rpc.com/?api-key=YOUR_API_KEY
    ```
  </Tab>
</Tabs>

## Điểm cuối WebSocket

Nếu đang sử dụng WebSocket, hãy cập nhật cả các điểm cuối đó:

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

// After
const ws = new WebSocket("wss://beta.helius-rpc.com/?api-key=YOUR_API_KEY");
```

## Danh sách kiểm tra khi di chuyển

<Steps>
  <Step title="Update endpoint URL">
    Thay đổi `mainnet.helius-rpc.com` thành `beta.helius-rpc.com`
  </Step>

  <Step title="Test in development">
    Xác minh tất cả lệnh gọi RPC đều hoạt động và xác thực thành công
  </Step>

  <Step title="Monitor performance">
    Kiểm tra các chỉ số để xác nhận độ trễ và thời gian phản hồi đã được cải thiện
  </Step>

  <Step title="Deploy to production">
    Phát hành các thay đổi bằng quy trình triển khai tiêu chuẩn của bạn
  </Step>
</Steps>

## Phát hành dần (Không bắt buộc)

Để di chuyển an toàn hơn, bạn có thể sử dụng biến môi trường hoặc cờ tính năng:

```javascript theme={"system"}
// Environment-based
const endpoint = process.env.USE_GATEKEEPER
  ? "https://beta.helius-rpc.com"
  : "https://mainnet.helius-rpc.com";

const connection = new Connection(
  `${endpoint}?api-key=${YOUR_API_KEY}`,
  'confirmed'
);
```

```javascript theme={"system"}
// Percentage rollout (10% of traffic)
const useGatekeeper = Math.random() < 0.1;
const endpoint = useGatekeeper
  ? "https://beta.helius-rpc.com"
  : "https://mainnet.helius-rpc.com";
```

## Khôi phục

Nếu cần, chỉ cần chuyển về điểm cuối tiêu chuẩn:

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

## Khắc phục sự cố

<AccordionGroup>
  <Accordion title="Getting 401 Unauthorized errors">
    Xác minh khóa API đã được thêm vào: `?api-key=YOUR_API_KEY`
  </Accordion>

  <Accordion title="Not seeing performance improvements">
    * Kiểm thử từ môi trường production của bạn (không phải môi trường phát triển cục bộ)
    * Xác minh bạn không vượt quá giới hạn tốc độ (kiểm tra lỗi 429)
    * Liên hệ bộ phận hỗ trợ nếu sự cố vẫn tiếp diễn
  </Accordion>

  <Accordion title="WebSocket connections failing">
    * Sử dụng `wss://` (không phải `ws://`)
    * Đảm bảo khóa API có trong URL
    * Kiểm tra cài đặt tường lửa
  </Accordion>

  <Accordion title="Response formats look different">
    Gatekeeper trả về các phản hồi giống hệt nhau. Hãy liên hệ ngay với bộ phận hỗ trợ nếu bạn thấy có sự khác biệt.
  </Accordion>
</AccordionGroup>

## Bạn cần trợ giúp?

* **Email**: [support@helius.dev](mailto:support@helius.dev)
* **Discord**: [https://discord.com/invite/6GXdee3gBj](https://discord.com/invite/6GXdee3gBj)
* **Tài liệu**: [Tổng quan về Gatekeeper](/docs/vi/gatekeeper/overview)

<Card title="Questions about migration?" icon="comments" href="https://discord.com/invite/6GXdee3gBj">
  Tham gia Discord của chúng tôi để trò chuyện với đội ngũ và các nhà phát triển khác
</Card>
