> ## 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 lấy NFT Solana: Tài sản, bộ sưu tập và bằng chứng

> Truy xuất và truy vấn NFT Solana, NFT nén, phiên bản và bằng chứng bằng Helius DAS API. Hướng dẫn đầy đủ kèm ví dụ mã và các phương pháp hay nhất.

## Tổng quan

Hướng dẫn này trình bày cách đọc NFT và vật phẩm sưu tầm kỹ thuật số bằng Helius Digital Asset Standard (DAS) API: lấy một tài sản, liệt kê NFT của ví, truy vấn theo bộ sưu tập hoặc người tạo, làm việc với NFT nén và bằng chứng Merkle, liệt kê các phiên bản và đọc lịch sử giao dịch.

Đối với token có thể thay thế — số dư, nguồn cung, người nắm giữ và giá — hãy xem [hướng dẫn Lấy token SPL](/docs/vi/das/get-tokens). Các phương thức `getAsset` và `getAssetsByOwner` đều hỗ trợ cả NFT lẫn token; trang này tập trung vào quy trình làm việc với NFT và vật phẩm sưu tầm.

## Khi nào nên sử dụng

Sử dụng các phương thức trên trang này khi cần:

* Hiển thị siêu dữ liệu, hình ảnh và thuộc tính của một NFT
* Liệt kê mọi NFT mà một ví sở hữu cho danh mục đầu tư hoặc thư viện
* Cung cấp dữ liệu cho chợ giao dịch hoặc trình khám phá bằng các truy vấn theo bộ sưu tập và người tạo
* Xác minh hoặc chuyển NFT nén (cần có bằng chứng Merkle)
* Hiển thị lịch sử giao dịch trên chuỗi của NFT
* Liệt kê các phiên bản được tạo từ NFT gốc

## Các phương thức NFT

Bắt đầu với `getAsset` cho một NFT hoặc `getAssetsByOwner` cho bộ sưu tập của một ví. Mỗi thẻ liên kết đến tài liệu tham khảo API đầy đủ tương ứng.

<CardGroup cols={2}>
  <Card title="getAsset" icon="image" href="/docs/vi/api-reference/das/getasset">
    Dữ liệu đầy đủ của một NFT theo ID.
  </Card>

  <Card title="getAssetsByOwner" icon="wallet" href="/docs/vi/api-reference/das/getassetsbyowner">
    Tất cả NFT do một ví nắm giữ.
  </Card>

  <Card title="searchAssets" icon="magnifying-glass" href="/docs/vi/das/search">
    Lọc theo bộ sưu tập, người tạo, thuộc tính và nhiều tiêu chí khác — xem hướng dẫn Tìm kiếm tài sản.
  </Card>

  <Card title="getAssetsByCreator" icon="user" href="/docs/vi/api-reference/das/getassetsbycreator">
    Tất cả tài sản do một người tạo phát hành.
  </Card>

  <Card title="getAssetsByGroup" icon="layer-group" href="/docs/vi/api-reference/das/getassetsbygroup">
    Tất cả tài sản trong một bộ sưu tập.
  </Card>

  <Card title="getSignaturesForAsset" icon="clock-rotate-left" href="/docs/vi/api-reference/das/getsignaturesforasset">
    Lịch sử giao dịch của một tài sản.
  </Card>

  <Card title="getNftEditions" icon="copy" href="/docs/vi/api-reference/das/getnfteditions">
    Các phiên bản được tạo từ NFT gốc.
  </Card>

  <Card title="getAssetProof" icon="shield-check" href="/docs/vi/api-reference/das/getassetproof">
    Bằng chứng Merkle cho một NFT nén.
  </Card>
</CardGroup>

### Lấy một NFT

Truy xuất đầy đủ siêu dữ liệu, quyền sở hữu và dữ liệu bộ sưu tập của một NFT theo ID:

```typescript theme={"system"}
const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: '1',
    method: 'getAsset',
    params: { id: 'F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk' },
  }),
});

const { result } = await response.json();
console.log(result.content.metadata.name, result.ownership.owner);
```

### Các truy vấn NFT khác

<AccordionGroup>
  <Accordion title="List a wallet's NFTs — getAssetsByOwner">
    ```typescript theme={"system"}
    const getNFTsByOwner = async (ownerAddress) => {
      const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          jsonrpc: '2.0',
          id: '1',
          method: 'getAssetsByOwner',
          params: { ownerAddress, page: 1, limit: 10 },
        }),
      });

      const { result } = await response.json();
      return result;
    };

    getNFTsByOwner('86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY');
    ```
  </Accordion>

  <Accordion title="By creator — getAssetsByCreator">
    ```typescript theme={"system"}
    const getAssetsByCreator = async (creatorAddress) => {
      const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          jsonrpc: '2.0',
          id: '1',
          method: 'getAssetsByCreator',
          params: { creatorAddress, page: 1, limit: 100 },
        }),
      });

      const { result } = await response.json();
      return result;
    };

    getAssetsByCreator('9uBX3ASjxWvNBAD1xjbVaKA74mWGZys3RGSF7DdeDD3F');
    ```
  </Accordion>

  <Accordion title="By collection — getAssetsByGroup">
    ```typescript theme={"system"}
    const getAssetsByCollection = async (collectionAddress) => {
      const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          jsonrpc: '2.0',
          id: '1',
          method: 'getAssetsByGroup',
          params: { groupKey: 'collection', groupValue: collectionAddress, page: 1, limit: 100 },
        }),
      });

      const { result } = await response.json();
      return result;
    };

    getAssetsByCollection('J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w');
    ```
  </Accordion>

  <Accordion title="Transaction history — getSignaturesForAsset">
    ```typescript theme={"system"}
    const getNFTTransactionHistory = async (mintAddress) => {
      const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
          jsonrpc: '2.0',
          id: '1',
          method: 'getSignaturesForAsset',
          params: { id: mintAddress, page: 1, limit: 100 },
        }),
      });

      const { result } = await response.json();
      return result;
    };

    getNFTTransactionHistory('FNt6A9Mfnqbwc1tY7uwAguKQ1JcpBrxmhczDgbdJy5AC');
    ```
  </Accordion>
</AccordionGroup>

## NFT nén

NFT nén trạng thái (cNFT) được **đọc** bằng các phương thức giống như NFT thông thường — `getAsset`, `getAssetsByOwner` và `searchAssets` đều trả về các NFT này. Có hai điểm dành riêng cho tính năng nén:

* **Bằng chứng Merkle** — các thao tác trên chuỗi như chuyển và đốt cần bằng chứng từ `getAssetProof`.
* **Lịch sử** — sử dụng `getSignaturesForAsset` (được trình bày ở trên) để lấy lịch sử giao dịch của cNFT.

<Accordion title="Get a Merkle proof — getAssetProof">
  ```typescript theme={"system"}
  const getProof = async (id) => {
    const response = await fetch('https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: '1',
        method: 'getAssetProof',
        params: { id },
      }),
    });

    const { result } = await response.json();
    return result; // { root, proof, node_index, leaf, tree_id }
  };

  getProof('Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss');
  ```
</Accordion>

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

* Sử dụng [phân trang](/docs/vi/das/pagination) cho các phương thức trả về tập kết quả lớn.
* Xử lý lỗi bằng try/catch và thử lại các lỗi tạm thời với thời gian chờ tăng theo cấp số nhân.
* Lưu phản hồi vào bộ nhớ đệm khi phù hợp để giảm số lệnh gọi API.
* Sử dụng `getAssetBatch` thay vì thực hiện nhiều lệnh gọi `getAsset` riêng lẻ khi có nhiều ID.

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

<CardGroup cols={3}>
  <Card title="Get SPL Tokens" icon="coins" href="/docs/vi/das/get-tokens">
    Số dư, nguồn cung, người nắm giữ và giá của token có thể thay thế.
  </Card>

  <Card title="Search Assets" icon="magnifying-glass" href="/docs/vi/das/search">
    Lọc NFT theo bộ sưu tập, người tạo và thuộc tính.
  </Card>

  <Card title="DAS API FAQ" icon="book" href="/docs/vi/faqs/das-api">
    Các câu hỏi thường gặp về tài sản, dữ liệu giá và cách sử dụng.
  </Card>
</CardGroup>
