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

# Bắt đầu nhanh với tính năng truyền phát dữ liệu Solana

> Khởi chạy luồng dữ liệu Solana theo thời gian thực đầu tiên trong chưa đầy 5 phút. Hướng dẫn thiết lập LaserStream gRPC, LaserStream WebSocket và Webhooks.

## Thiết lập nhanh

Bắt đầu truyền phát dữ liệu Solana chỉ trong vài phút với các ví dụ mã có thể chạy ngay. Chọn phương pháp dựa trên nhu cầu của bạn (sắp xếp từ nhanh nhất đến chậm nhất):

| Phương pháp             | Phù hợp nhất cho                                                                                                         | Gói bắt buộc                                                                  |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
| **\[Preconfirmations]** | propAMM, bot săn giao dịch, bot sao chép giao dịch, bot thanh lý — tín hiệu giao dịch sớm nhất                           | Professional+                                                                 |
| **Shred Delivery**      | propAMM, bot săn giao dịch, bot sao chép giao dịch, bot thanh lý, kinh doanh chênh lệch giá — dữ liệu trước khi thực thi | Tất cả các gói ([tiện ích bổ sung trả phí](/docs/vi/billing/plans#shred-delivery)) |
| **LaserStream gRPC**    | Dịch vụ backend quan trọng                                                                                               | Tất cả các gói (Devnet), Business+ (Mainnet)                                  |
| **LaserStream WSS**     | Hầu hết ứng dụng, giao diện người dùng theo thời gian thực, khả năng tương thích rộng                                    | Free+ (tiện ích mở rộng Helius: Developer+)                                   |
| **Webhooks**            | Thông báo máy chủ, ứng dụng hướng sự kiện                                                                                | Free+                                                                         |

<Tip>
  Bạn cần shred thô? [Đăng ký trong thẻ Shreds
  ](https://dashboard.helius.dev/shred-delivery-seats) trên Bảng điều khiển Helius
  của bạn. Xem [Cách đăng ký Shred thô](/docs/vi/shred-delivery/raw-shreds)
  để biết các bước thiết lập.
</Tip>

## Lựa chọn 1: LaserStream gRPC

Lựa chọn đáng tin cậy nhất, hỗ trợ [phát lại dữ liệu lịch sử trong 48 giờ](/docs/vi/laserstream/historical-replay) và chuyển đổi dự phòng giữa nhiều node. Phù hợp nhất cho các backend và trình lập chỉ mục quan trọng.

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

```typescript theme={"system"}
import {
  subscribe,
  CommitmentLevel,
  LaserstreamConfig,
  SubscribeRequest,
} from "helius-laserstream";

async function main() {
  const subscriptionRequest: SubscribeRequest = {
    transactions: {
      "token-filter": {
        // user-defined label for this filter
        accountInclude: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
        accountExclude: [],
        accountRequired: [],
        vote: false,
        failed: false,
      },
    },
    commitment: CommitmentLevel.CONFIRMED,
    accounts: {},
    slots: {},
    transactionsStatus: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    accountsDataSlice: [],
  };

  const config: LaserstreamConfig = {
    apiKey: "YOUR_API_KEY",
    endpoint: "https://laserstream-mainnet-ewr.helius-rpc.com",
  };

  await subscribe(
    config,
    subscriptionRequest,
    async (data) => {
      console.log(data);
    },
    async (error) => {
      console.error(error);
    },
  );
}

main().catch(console.error);
```

<CardGroup cols={2}>
  <Card title="LaserStream Guide" icon="book" href="/docs/vi/laserstream">
    Tài liệu LaserStream đầy đủ, bao gồm tính năng phát lại dữ liệu lịch sử
  </Card>

  <Card title="Get started" icon="arrow-right" href="https://dashboard.helius.dev/laserstream">
    Lấy token và endpoint LaserStream gRPC trong bảng điều khiển Helius của bạn
  </Card>
</CardGroup>

## Lựa chọn 2: LaserStream WebSocket

[LaserStream WebSocket](/docs/vi/rpc/websocket) cung cấp [các phương thức đăng ký Solana tiêu chuẩn](/docs/vi/api-reference/rpc/websocket-methods) và các tiện ích mở rộng Helius như `transactionSubscribe` trên một endpoint hợp nhất duy nhất. Đây là lựa chọn lý tưởng cho các máy khách trình duyệt/giao diện người dùng và khả năng tương thích rộng với hệ sinh thái.

```javascript theme={"system"}
const WebSocket = require("ws");

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

ws.on("open", () => {
  console.log("WebSocket connected");

  // Helius extension: transactionSubscribe with rich filtering
  ws.send(
    JSON.stringify({
      jsonrpc: "2.0",
      id: 1,
      method: "transactionSubscribe",
      params: [
        {
          accountInclude: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
          vote: false,
          failed: false,
        },
        {
          commitment: "confirmed",
          encoding: "jsonParsed",
          transactionDetails: "full",
        },
      ],
    }),
  );

  // Keep connection alive
  setInterval(() => ws.ping(), 30000);
});

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

**Thay `YOUR_API_KEY`** bằng khóa của bạn từ [dashboard.helius.dev](https://dashboard.helius.dev).

<Card title="LaserStream WebSocket Overview" icon="arrow-right" href="/docs/vi/rpc/websocket">
  Tất cả phương thức đăng ký (Solana tiêu chuẩn + tiện ích mở rộng Helius), kèm tài liệu
  tham khảo tham số và ví dụ
</Card>

## Lựa chọn 3: Webhooks

Dành cho các ứng dụng phía máy chủ cần nhận thông báo sự kiện mà không phải duy trì kết nối liên tục.

```bash theme={"system"}
# Create a webhook
curl -X POST "https://mainnet.helius-rpc.com/v0/webhooks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhookURL": "https://your-server.com/webhook",
    "transactionTypes": ["Any"],
    "accountAddresses": ["YOUR_ACCOUNT_ADDRESS"],
    "webhookType": "enhanced"
  }'
```

```javascript theme={"system"}
// Handle webhook events (Express.js example)
app.post("/webhook", (req, res) => {
  req.body.forEach((event) => {
    console.log("Blockchain event:", event);
  });
  res.status(200).send("OK");
});
```

<Card title="Webhooks Guide" icon="arrow-right" href="/docs/vi/webhooks">
  Hướng dẫn đầy đủ về cách thiết lập webhook và xử lý sự kiện
</Card>

## Các trường hợp sử dụng phổ biến

**Giám sát hoạt động chuyển token**

```javascript theme={"system"}
// Subscribe to Token Program activity
method: "programSubscribe",
params: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", {...}]
```

**Theo dõi giao dịch Pump.fun**

```javascript theme={"system"}
// Subscribe to Pump.fun program transactions
method: "transactionSubscribe",
params: [
  {
    accountInclude: ["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"],
    vote: false,
    failed: false
  },
  { commitment: "confirmed" }
]
```

**Theo dõi hoạt động của ví**

```javascript theme={"system"}
// Monitor specific wallet
method: "accountSubscribe",
params: ["WALLET_ADDRESS", {...}]
```

## Các bước tiếp theo

<CardGroup cols={2}>
  <Card title="Streaming Overview" icon="play" href="/docs/vi/data-streaming">
    Tìm hiểu về tất cả các lựa chọn truyền phát và thời điểm sử dụng từng lựa chọn
  </Card>

  <Card title="API Reference" icon="book" href="/docs/vi/api-reference">
    Tài liệu đầy đủ về các phương thức và tham số
  </Card>
</CardGroup>

**Bạn cần trợ giúp?** Tham gia [Discord](https://discord.com/invite/6GXdee3gBj) của chúng tôi hoặc xem [tài liệu hỗ trợ](/docs/vi/support).
