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

# getFeeForMessage

> Lấy mức phí mà mạng sẽ tính cho một Message cụ thể.

## Tham số yêu cầu

<ParamField body="transaction" type="string" required>
  Thông điệp giao dịch Solana đã tuần tự hóa và mã hóa Base64 dùng để tính chính xác mức phí.
</ParamField>

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

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

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


## OpenAPI

````yaml vi/openapi/rpc-http/getFeeForMessage.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: >-
    API tính phí giao dịch để ước tính chính xác chi phí giao dịch Solana dựa
    trên thông điệp đã tuần tự hóa, giúp lập ngân sách phí gas chính xác trước
    khi gửi.
  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: getFeeForMessage
      description: >
        Tính chính xác chi phí giao dịch cho một thông điệp Solana đã tuần tự
        hóa cụ thể.

        API ước tính phí này cung cấp phép tính phí SOL chính xác dựa trên cấu
        trúc thông điệp 

        giao dịch thực tế, cho kết quả chính xác hơn so với các ước tính phí
        tổng quát. 

        Bằng cách phân tích chính xác các thao tác trong thông điệp đã được tuần
        tự hóa trước, API xác định 

        chính xác chi phí tính bằng lamport sẽ bị tính. Tính năng này rất cần
        thiết cho các ứng dụng ví cần 

        ước tính phí chính xác, sàn giao dịch tính phí rút tiền, DApp lập ngân
        sách giao dịch, 

        bộ xử lý thanh toán cần tính toán chính xác chi phí và mọi ứng dụng 

        cần biết chính xác mức phí trước khi gửi giao dịch đến mạng Solana.
      operationId: getFeeForMessage
      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:
                    - getFeeForMessage
                  example: getFeeForMessage
                  default: getFeeForMessage
                params:
                  type: array
                  description: Các tham số của phương thức.
                  default:
                    - >-
                      AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA
                  items:
                    oneOf:
                      - type: string
                        description: >-
                          Thông điệp giao dịch Solana đã tuần tự hóa và mã hóa
                          Base64 dùng để tính chính xác mức phí.
                        example: >-
                          AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA
                      - type: object
                        description: Đối tượng cấu hình chứa các tham số không bắt buộc.
                        properties:
                          commitment:
                            type: string
                            description: Mức cam kết cho yêu cầu.
                            enum:
                              - confirmed
                              - finalized
                            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
      responses:
        '200':
          description: Đã truy xuất thành công mức phí cho thông điệp đã cho.
          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:
                    type: object
                    description: Thông tin phí cho thông điệp.
                    properties:
                      context:
                        type: object
                        description: Ngữ cảnh của phản hồi.
                        properties:
                          slot:
                            type: integer
                            description: Slot tại đó phí được tính.
                            example: 5068
                      value:
                        type: integer
                        nullable: true
                        description: >-
                          Phí giao dịch chính xác tính bằng lamport (1 SOL =
                          1.000.000.000 lamport) cần thiết để xử lý thông điệp
                          cụ thể này trên mạng.
                        example: 5000
        '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 có
            định dạng sai.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: Invalid params
                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
                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
                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
                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
                id: '1'
        '504':
          description: Hết thời gian chờ cổng kết nối - 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
                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).

````