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

# getProgramAccounts

> Trả về tất cả tài khoản thuộc sở hữu của Pubkey chương trình được cung cấp.

<Info>
  **Tính năng mới**: `getProgramAccounts` hiện hỗ trợ tham số `changedSinceSlot` để cập nhật tăng dần. Khi được chỉ định, phương thức chỉ trả về các tài khoản đã được sửa đổi tại hoặc sau số slot đã cho. Tính năng này rất phù hợp cho các quy trình lập chỉ mục theo thời gian thực và đồng bộ hóa dữ liệu.
</Info>

## Tham số yêu cầu

<ParamField body="address" type="string" required>
  Khóa công khai (địa chỉ) của chương trình Solana cần truy vấn tài khoản, dưới dạng chuỗi được mã hóa base-58.
</ParamField>

<ParamField body="commitment" type="string">
  Mức cam kết cho yêu cầu.

  * `confirmed`
  * `finalized`
  * `processed`
</ParamField>

<ParamField body="minContextSlot" type="number">
  Slot tối thiểu mà tại đó yêu cầu có thể được đánh giá.
</ParamField>

<ParamField body="withContext" type="boolean">
  Bao bọc kết quả trong một đối tượng JSON RpcResponse.
</ParamField>

<ParamField body="encoding" type="string">
  Định dạng mã hóa cho dữ liệu tài khoản được trả về.

  * `jsonParsed`
  * `base58`
  * `base64`
  * `base64+zstd`
</ParamField>

<ParamField body="dataSlice" type="object">
  Yêu cầu một phần dữ liệu của tài khoản.
</ParamField>

<ParamField body="dataSlice.length" type="number">
  Số byte cần trả về.
</ParamField>

<ParamField body="dataSlice.offset" type="number">
  Độ lệch byte để bắt đầu đọc.
</ParamField>

<ParamField body="changedSinceSlot" type="number">
  Chỉ trả về các tài khoản đã được sửa đổi tại hoặc sau số slot này. Hữu ích cho các bản cập nhật tăng dần.
</ParamField>

<ParamField body="filters" type="array">
  Hệ thống lọc mạnh mẽ để truy vấn hiệu quả các mẫu dữ liệu tài khoản Solana cụ thể.
</ParamField>


## OpenAPI

````yaml vi/openapi/rpc-http/getProgramAccounts.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: >-
    API lập chỉ mục tài khoản chương trình Solana nâng cao để truy vấn và lọc
    các tài khoản thuộc sở hữu của những chương trình cụ thể, với khả năng lọc
    dữ liệu mạnh mẽ.
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://mainnet.helius-rpc.com
    description: Điểm cuối RPC Mainnet
  - url: https://devnet.helius-rpc.com
    description: Điểm cuối RPC Devnet
security: []
paths:
  /:
    post:
      tags:
        - RPC
      summary: getProgramAccounts
      description: >
        Truy xuất tất cả tài khoản thuộc sở hữu của một chương trình Solana cụ
        thể với khả năng lọc mạnh mẽ.

        API thiết yếu này cho phép nhà phát triển truy vấn hiệu quả các cấu trúc
        dữ liệu trên chuỗi được sử dụng bởi

        bất kỳ chương trình nào, với khả năng lọc nâng cao theo kích thước tài
        khoản, nội dung bộ nhớ và các tiêu chí khác.

        Phù hợp để lập chỉ mục các bộ sưu tập NFT, pool thanh khoản DEX, vị thế
        cho vay, đề xuất quản trị

        và dữ liệu dành riêng cho giao thức khác được lưu trữ trên blockchain
        Solana. Hỗ trợ nhiều định dạng mã hóa dữ liệu

        để đạt hiệu quả phân tích cú pháp tối ưu.
      operationId: getProgramAccounts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - jsonrpc
                - id
                - method
                - params
              properties:
                jsonrpc:
                  type: string
                  description: Phiên bản giao thức JSON-RPC.
                  enum:
                    - '2.0'
                  example: '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: Mã định danh duy nhất cho yêu cầu.
                  example: '1'
                  default: '1'
                method:
                  type: string
                  description: Tên của phương thức RPC cần gọi.
                  enum:
                    - getProgramAccounts
                  example: getProgramAccounts
                  default: getProgramAccounts
                params:
                  type: array
                  description: Các tham số cho phương thức.
                  default:
                    - 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                  items:
                    oneOf:
                      - type: string
                        description: >-
                          Khóa công khai (địa chỉ) của chương trình Solana cần
                          truy vấn tài khoản, dưới dạng chuỗi được mã hóa
                          base-58.
                        example: 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                      - type: object
                        description: >-
                          Các tùy chọn cấu hình nâng cao để tối ưu hóa truy vấn
                          tài khoản chương trình.
                        properties:
                          commitment:
                            type: string
                            description: Mức độ cam kết cho yêu cầu.
                            enum:
                              - confirmed
                              - finalized
                              - processed
                            example: finalized
                          minContextSlot:
                            type: integer
                            description: >-
                              Slot tối thiểu mà tại đó yêu cầu có thể được đánh
                              giá.
                            example: 1000
                          withContext:
                            type: boolean
                            description: >-
                              Bao bọc kết quả trong một đối tượng JSON
                              RpcResponse.
                            example: true
                          encoding:
                            type: string
                            description: >-
                              Định dạng mã hóa cho dữ liệu tài khoản được trả
                              về.
                            enum:
                              - jsonParsed
                              - base58
                              - base64
                              - base64+zstd
                            example: jsonParsed
                          dataSlice:
                            type: object
                            description: Yêu cầu một phần dữ liệu của tài khoản.
                            properties:
                              length:
                                type: integer
                                description: Số byte cần trả về.
                                example: 50
                              offset:
                                type: integer
                                description: Độ lệch byte để bắt đầu đọc.
                                example: 0
                          changedSinceSlot:
                            type: integer
                            description: >-
                              Chỉ trả về các tài khoản đã được sửa đổi tại hoặc
                              sau số slot này. Hữu ích cho các bản cập nhật tăng
                              dần.
                            example: 464175999
                          filters:
                            type: array
                            description: >-
                              Hệ thống lọc mạnh mẽ để truy vấn hiệu quả các mẫu
                              dữ liệu tài khoản Solana cụ thể.
                            items:
                              oneOf:
                                - type: object
                                  description: >-
                                    Lọc tài khoản Solana theo kích thước dữ liệu
                                    chính xác tính bằng byte.
                                  properties:
                                    dataSize:
                                      type: integer
                                      description: >-
                                        Kích thước chính xác của dữ liệu tài
                                        khoản tính bằng byte để lọc.
                                      example: 17
                                - type: object
                                  description: >-
                                    Lọc tài khoản Solana bằng cách so sánh dữ
                                    liệu tại các độ lệch bộ nhớ cụ thể (bộ lọc
                                    mạnh nhất).
                                  properties:
                                    memcmp:
                                      type: object
                                      description: >-
                                        Bộ lọc so sánh bộ nhớ để tìm các tài
                                        khoản có mẫu dữ liệu cụ thể.
                                      properties:
                                        offset:
                                          type: integer
                                          description: >-
                                            Độ lệch byte trong dữ liệu tài khoản để
                                            thực hiện phép so sánh.
                                          example: 4
                                        bytes:
                                          type: string
                                          description: >-
                                            Dữ liệu được mã hóa base-58 để so sánh
                                            tại vị trí độ lệch đã chỉ định.
                                          example: 3Mc6vR
      responses:
        '200':
          description: Đã truy xuất thành công các tài khoản chương trình.
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: Phiên bản giao thức JSON-RPC.
                    enum:
                      - '2.0'
                    example: '2.0'
                  id:
                    type: string
                    description: Mã định danh khớp với yêu cầu.
                    example: '1'
                  result:
                    oneOf:
                      - type: array
                        description: Danh sách tài khoản chương trình.
                        items:
                          type: object
                          properties:
                            pubkey:
                              type: string
                              description: >-
                                Pubkey của tài khoản dưới dạng chuỗi được mã hóa
                                base-58.
                              example: CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY
                            account:
                              type: object
                              description: Thông tin chi tiết về tài khoản.
                              properties:
                                lamports:
                                  type: integer
                                  description: Số lamport được gán cho tài khoản này.
                                  example: 15298080
                                owner:
                                  type: string
                                  description: >-
                                    Pubkey được mã hóa base-58 của chương trình
                                    mà tài khoản này được gán cho.
                                  example: 4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T
                                data:
                                  type: array
                                  description: >-
                                    Dữ liệu tài khoản ở định dạng nhị phân được
                                    mã hóa hoặc JSON.
                                  items:
                                    type: string
                                  example:
                                    - 2R9jLfiAQ9bgdcw6h8s44439
                                    - base58
                                executable:
                                  type: boolean
                                  description: >-
                                    Cho biết tài khoản có chứa chương trình hay
                                    không.
                                  example: false
                                rentEpoch:
                                  type: integer
                                  description: >-
                                    Epoch mà tại đó tài khoản này sẽ phải trả
                                    phí thuê tiếp theo.
                                  example: 28
                                space:
                                  type: integer
                                  description: Kích thước dữ liệu của tài khoản.
                                  example: 42
        '400':
          description: >-
            Yêu cầu không hợp lệ - Tham số yêu cầu không hợp lệ hoặc yêu cầu sai
            định dạng.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: Invalid params
                  data: {}
                id: '1'
        '401':
          description: Không được phép - Khóa API không hợp lệ hoặc bị thiếu.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: Unauthorized
                  data: {}
                id: '1'
        '429':
          description: Quá nhiều yêu cầu - Đã vượt quá giới hạn tốc độ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: Too many requests
                  data: {}
                id: '1'
        '500':
          description: Lỗi máy chủ nội bộ - Đã xảy ra lỗi trên máy chủ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: Internal error
                  data: {}
                id: '1'
        '503':
          description: Dịch vụ không khả dụng - Dịch vụ tạm thời không khả dụng.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: Service unavailable
                  data: {}
                id: '1'
        '504':
          description: Cổng kết nối hết thời gian chờ - Yêu cầu đã hết thời gian chờ.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: Gateway timeout
                  data: {}
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: Phiên bản giao thức JSON-RPC.
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: Mã lỗi.
              example: -32602
            message:
              type: string
              description: Thông báo lỗi.
            data:
              type: object
              description: Dữ liệu bổ sung về lỗi.
        id:
          type: string
          description: Mã định danh khớp với yêu cầu.
          example: '1'
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: >-
        Khóa API Helius của bạn. Bạn có thể nhận khóa miễn phí trong [bảng điều
        khiển](https://dashboard.helius.dev/api-keys).

````