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

# Sender chỉ dùng SWQOS: Gửi với độ trễ thấp và chi phí tối ưu

> Gửi giao dịch Solana qua tuyến chỉ dùng SWQOS được tối ưu chi phí của Helius Sender với mức tiền boa tối thiểu 0.000005 SOL. Độ trễ thấp với mức tiền boa thấp nhất.

## Tổng quan

Chỉ dùng SWQOS là cấp [Helius Sender](/docs/vi/sending-transactions/sender) được tối ưu chi phí. Cấp này định tuyến giao dịch của bạn qua một tuyến SWQOS (chất lượng dịch vụ theo trọng số stake) nhanh duy nhất với **mức tiền boa tối thiểu thấp nhất trong mọi cấp Sender: 0.000005 SOL**.

Sử dụng cấp này khi bạn muốn gửi với độ trễ thấp và mức tiền boa thấp nhất. Đối với các giao dịch có mức cạnh tranh cao, khi tốc độ xác nhận là yếu tố quan trọng nhất, hãy sử dụng cấp [Sender Max](/docs/vi/sending-transactions/sender-max).

<CardGroup cols={2}>
  <Card title="Lowest Tip" icon="dollar-sign">
    Mức tiền boa tối thiểu chỉ 0.000005 SOL — cách tiết kiệm nhất để sử dụng Sender
  </Card>

  <Card title="Single Fast Path" icon="bolt">
    Chỉ định tuyến qua cơ sở hạ tầng SWQOS để phân phối với độ trễ thấp
  </Card>

  <Card title="No Credits" icon="coins">
    Khả dụng trên mọi gói mà không tiêu tốn tín dụng API
  </Card>

  <Card title="Single Pathway" icon="circle-info">
    Chỉ định tuyến qua một tuyến SWQOS — để định tuyến đa tuyến và xác nhận nhanh
    nhất, hãy sử dụng cấp Sender Max
  </Card>
</CardGroup>

## Khi nào nên sử dụng chế độ chỉ dùng SWQOS

<CardGroup cols={2}>
  <Card title="Good fit" icon="circle-check">
    Giao dịch chú trọng chi phí, khối lượng giao dịch lớn và các luồng mà một
    tuyến nhanh duy nhất đủ để xác nhận một cách ổn định.
  </Card>

  <Card title="Consider Sender Max instead" icon="trophy" href="/docs/vi/sending-transactions/sender-max">
    Các tài khoản có mức cạnh tranh cao, đợt ra mắt cạnh tranh hoặc bất kỳ giao dịch nào
    cần được xác nhận nhanh nhất có thể.
  </Card>
</CardGroup>

## Cách bật chế độ chỉ dùng SWQOS

Thêm tham số truy vấn `swqos_only=true` vào URL của bất kỳ điểm cuối Sender nào. Sử dụng điểm cuối HTTPS toàn cầu cho frontend hoặc điểm cuối HTTP theo khu vực gần máy chủ của bạn nhất cho backend.

**Frontend / trình duyệt (HTTPS toàn cầu):**

```
https://sender.helius-rpc.com/fast?swqos_only=true
```

**Backend / máy chủ (HTTP theo khu vực):**

```
http://slc-sender.helius-rpc.com/fast?swqos_only=true   # Salt Lake City
http://ewr-sender.helius-rpc.com/fast?swqos_only=true   # Newark
http://lon-sender.helius-rpc.com/fast?swqos_only=true   # London
http://fra-sender.helius-rpc.com/fast?swqos_only=true   # Frankfurt
http://ams-sender.helius-rpc.com/fast?swqos_only=true   # Amsterdam
http://sg-sender.helius-rpc.com/fast?swqos_only=true    # Singapore
http://tyo-sender.helius-rpc.com/fast?swqos_only=true   # Tokyo
```

Thao tác này chỉ định tuyến giao dịch của bạn qua SWQOS và áp dụng yêu cầu tiền boa tối thiểu thấp hơn là **0.000005 SOL**. Xem [tài liệu tham khảo về các điểm cuối Sender](/docs/vi/sending-transactions/sender#endpoint) để biết chi tiết về việc làm nóng kết nối.

<Tip>
  Bạn muốn tránh các trình xác thực có liên quan đến tấn công sandwich? Hãy thêm
  [`mev-protect=true`](/docs/vi/sending-transactions/mev-protect) cùng với `swqos_only`:
  `https://sender.helius-rpc.com/fast?swqos_only=true&mev-protect=true`.
</Tip>

## Yêu cầu

Giống như mọi cấp Sender, giao dịch chỉ dùng SWQOS phải bao gồm:

* **Tiền boa**: Một giao dịch chuyển SOL trị giá ít nhất **0.000005 SOL** đến một [tài khoản nhận tiền boa](/docs/vi/sending-transactions/sender#yêu-cầu) được chỉ định
* **Phí ưu tiên**: Một chỉ thị về giá đơn vị tính toán thông qua `ComputeBudgetProgram.setComputeUnitPrice`

Việc bỏ qua kiểm tra trước (`skipPreflight: true`) là không bắt buộc nhưng được khuyến nghị — các bước kiểm tra trước làm tăng độ trễ.

<Warning>
  Giao dịch của bạn phải chứa cả thao tác chuyển tiền boa và chỉ thị về giá đơn vị
  tính toán. Nếu thiếu một trong hai, giao dịch sẽ bị từ chối.
</Warning>

## Ví dụ mã

<Tabs>
  <Tab title="@solana/web3.js">
    ```typescript [expandable] theme={"system"}
    import { 
      Connection, 
      TransactionMessage,
      VersionedTransaction,
      SystemProgram, 
      PublicKey,
      Keypair,
      LAMPORTS_PER_SOL,
      ComputeBudgetProgram
    } from '@solana/web3.js';
    import bs58 from 'bs58';

    const PRIV_B58 = 'Your Private Key';
    const RECIPIENT = 'Recipient Address';
    const HELIUS_API_KEY = 'Your API Key';
    const TIP_ACCOUNTS = [
      "4ACfpUFoaSD9bfPdeu6DBt89gB6ENTeHBXCAi87NhDEE",
      "D2L6yPZ2FmmmTKPgzaMKdhu6EWZcTpLy1Vhx8uvZe7NZ",
      "9bnz4RShgq1hAnLnZbP8kbgBg1kEmcJBYQq3gQbmnSta",
      "5VY91ws6B2hMmBFRsXkoAAdsPHBJwRfBht4DXox3xkwn",
      "2nyhqdwKcJZR2vcqCyrYsaPVdAnFoJjiksCXJ7hfEYgD",
      "2q5pghRs6arqVjRvT5gfgWfWcHWmw1ZuCzphgd5KfWGJ",
      "wyvPkWjVZz1M8fHQnMMCDTQDbkManefNNhweYk5WkcF",
      "3KCKozbAaF75qEU33jtzozcJ29yJuaLJTy2jFdzUY8bT",
      "4vieeGHPYPG2MmyPRcYjdiDmmhN3ww7hsFNap8pVN3Ey",
      "4TQLFNWK8AovT1gFvda5jfw2oJeRMKEmw7aH6MGBJ3or"
    ];

    async function sendSwqosOnly(
      keypair: Keypair,
      recipientAddress: string
    ): Promise<string> {
      const connection = new Connection(
        `https://mainnet.helius-rpc.com/?api-key=${HELIUS_API_KEY}`
      );

      const { value: { blockhash } } = await connection.getLatestBlockhashAndContext('confirmed');

      // Build transaction: priority fee + recipient transfer + minimum SWQOS-only tip
      const transaction = new VersionedTransaction(
        new TransactionMessage({
          instructions: [
            ComputeBudgetProgram.setComputeUnitLimit({ units: 100_000 }),
            ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 200_000 }),
            SystemProgram.transfer({
              fromPubkey: keypair.publicKey,
              toPubkey: new PublicKey(recipientAddress),
              lamports: 0.001 * LAMPORTS_PER_SOL,
            }),
            SystemProgram.transfer({
              fromPubkey: keypair.publicKey,
              toPubkey: new PublicKey(TIP_ACCOUNTS[Math.floor(Math.random() * TIP_ACCOUNTS.length)]),
              lamports: 0.000005 * LAMPORTS_PER_SOL, // SWQOS-only minimum tip
            })
          ],
          payerKey: keypair.publicKey,
          recentBlockhash: blockhash,
        }).compileToV0Message()
      );

      transaction.sign([keypair]);

      // Note the ?swqos_only=true query parameter
      const SENDER_ENDPOINT = 'https://sender.helius-rpc.com/fast?swqos_only=true';
      // Backend: use the regional HTTP endpoint closest to your servers
      // const SENDER_ENDPOINT = 'http://slc-sender.helius-rpc.com/fast?swqos_only=true';

      const response = await fetch(SENDER_ENDPOINT, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          jsonrpc: '2.0',
          id: Date.now().toString(),
          method: 'sendTransaction',
          params: [
            Buffer.from(transaction.serialize()).toString('base64'),
            {
              encoding: 'base64',
              skipPreflight: true, // Optional: skip for lower latency
              maxRetries: 0
            }
          ]
        })
      });

      const json = await response.json();
      if (json.error) {
        throw new Error(json.error.message);
      }

      console.log('Transaction sent:', json.result);
      return json.result;
    }

    // Usage
    sendSwqosOnly(Keypair.fromSecretKey(bs58.decode(PRIV_B58)), RECIPIENT);
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={"system"}
    curl "https://sender.helius-rpc.com/fast?swqos_only=true" \
      -X POST \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "id": 1,
        "method": "sendTransaction",
        "params": [
          "BASE64_ENCODED_TRANSACTION",
          {
            "encoding": "base64",
            "skipPreflight": true,
            "maxRetries": 0
          }
        ]
      }'
    ```
  </Tab>
</Tabs>

<Note>
  Giao dịch trên vẫn sử dụng mức tiền boa 0.000005 SOL — mức tối thiểu khi chỉ dùng SWQOS.
  Tiền boa từ 0.000005 SOL đến 0.001 SOL được chấp nhận nhưng vẫn chỉ đi qua một
  tuyến SWQOS. Để định tuyến qua mọi tuyến nhằm được xác nhận nhanh nhất, hãy sử dụng
  cấp [Sender Max](/docs/vi/sending-transactions/sender-max) với mức tiền boa tối thiểu
  0.001 SOL.
</Note>

## Các phương pháp hay nhất

* **Chọn điểm cuối**: Sử dụng `https://sender.helius-rpc.com/fast?swqos_only=true` cho ứng dụng frontend để tránh các vấn đề về CORS. Đối với ứng dụng backend, hãy sử dụng điểm cuối HTTP theo khu vực gần máy chủ của bạn nhất.
* **Làm nóng kết nối**: Sử dụng [điểm cuối `/ping`](/docs/vi/sending-transactions/sender#làm-nóng-kết-nối) trong khoảng thời gian không hoạt động dài hơn 5 giây.
* **Phí ưu tiên**: Sử dụng [Helius Priority Fee API](/docs/vi/priority-fee-api) để nhận đề xuất theo thời gian thực.
* **Thử lại**: Đặt `maxRetries: 0` và triển khai logic thử lại của riêng bạn.

## Nội dung liên quan

<CardGroup cols={2}>
  <Card title="Sender Overview" icon="rocket" href="/docs/vi/sending-transactions/sender">
    Các khái niệm chung: điểm cuối, làm nóng kết nối, giới hạn tốc độ và TPS tùy chỉnh.
  </Card>

  <Card title="Sender Max Tier" icon="trophy" href="/docs/vi/sending-transactions/sender-max">
    Xác nhận nhanh nhất nhờ định tuyến đa tuyến qua mọi tuyến (tiền boa tối thiểu
    0.001 SOL).
  </Card>

  <Card title="Transaction Rebates" icon="coins" href="/docs/vi/sending-transactions/backrun-rebates">
    Đăng ký để nhận một phần MEV do giao dịch của bạn tạo ra, được thanh toán bằng SOL.
  </Card>

  <Card title="MEV Protect" icon="shield-halved" href="/docs/vi/sending-transactions/mev-protect">
    Định tuyến tránh các trình xác thực có liên hệ về mặt thống kê với tấn công sandwich.
  </Card>
</CardGroup>
