> ## Documentation Index
> Fetch the complete documentation index at: https://docs.raydium.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Xây dựng giao dịch swap (đầu vào cơ sở)

> Tạo một giao dịch swap được tuần tự hóa cho lượng đầu vào cố định.
Yêu cầu một phản hồi thành công từ `/compute/swap-base-in`.




## OpenAPI

````yaml /vi/api-reference/openapi/route-api-v2.yaml post /transaction/swap-base-in
openapi: 3.0.3
info:
  title: Raydium Transaction API (Route V2)
  version: 1.0.0
  description: >
    Công cụ xây dựng giao dịch swap phía máy chủ cho Solana. API này tạo ra giao
    dịch swap được tuần tự hóa mà không yêu cầu client chạy kết nối RPC hoặc SDK
    Raydium đầy đủ.


    Các phản hồi tuân theo định dạng phong bì tiêu chuẩn:

    - **Thành công**: `{ id: string, success: true, data: {...} }`

    - **Lỗi**: `{ id: string, success: false, msg: string }`
  contact:
    name: Raydium
    url: https://raydium.io
servers:
  - url: https://transaction-v1.raydium.io
    description: Mainnet
  - url: https://transaction-v1-devnet.raydium.io
    description: Devnet
security: []
tags:
  - name: Compute
    description: Các endpoint chỉ đọc để tính toán báo giá swap (không xây dựng giao dịch).
  - name: Transaction
    description: Xây dựng giao dịch swap được tuần tự hóa sẵn sàng ký và phát sóng.
paths:
  /transaction/swap-base-in:
    post:
      tags:
        - Transaction
      summary: Xây dựng giao dịch swap (đầu vào cơ sở)
      description: |
        Tạo một giao dịch swap được tuần tự hóa cho lượng đầu vào cố định.
        Yêu cầu một phản hồi thành công từ `/compute/swap-base-in`.
      operationId: buildSwapTransactionBaseIn
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuildTransactionRequest'
      responses:
        '200':
          description: Giao dịch được tuần tự hóa được xây dựng thành công.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionResponse'
        '400':
          description: Phần thân yêu cầu không hợp lệ hoặc trạng thái tính toán.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    BuildTransactionRequest:
      type: object
      required:
        - wallet
        - swapResponse
        - txVersion
        - computeUnitPriceMicroLamports
      properties:
        wallet:
          type: string
          description: Địa chỉ ví ký giao dịch (base58).
          example: '11111111111111111111111111111111'
        swapResponse:
          type: object
          description: Toàn bộ đối tượng phản hồi từ endpoint compute.
          properties:
            id:
              type: string
            success:
              type: boolean
            version:
              type: string
            data:
              type: object
        txVersion:
          type: string
          enum:
            - V0
            - LEGACY
          description: Phiên bản giao dịch Solana.
          example: V0
        computeUnitPriceMicroLamports:
          type: string
          description: Giá compute unit tính bằng micro-lamports (cho phí ưu tiên).
          example: '1000'
        wrapSol:
          type: boolean
          description: Có nên wrap SOL nếu đầu vào là SOL gốc hay không.
          example: false
        unwrapSol:
          type: boolean
          description: Có nên unwrap WSOL thành SOL ở đầu ra hay không.
          example: false
        inputAccount:
          type: string
          description: >-
            Địa chỉ token account tùy chọn cho đầu vào. Bắt buộc nếu không wrap
            SOL.
          example: TokenAccount1111111111111111111111111111111111
        outputAccount:
          type: string
          description: Địa chỉ token account tùy chọn cho đầu ra.
          example: TokenAccount2222222222222222222222222222222222
        jitoInfo:
          type: object
          description: Tham số bundle Jito tùy chọn cho bảo vệ MEV.
          properties:
            address:
              type: string
              description: Địa chỉ gửi bundle Jito.
            amount:
              type: string
              description: Số tiền tip bundle tính bằng lamports.
        referrerWallet:
          type: string
          description: Địa chỉ ví referrer tùy chọn để thu thập phí.
          example: ReferrerWallet1111111111111111111111111111111111
    TransactionResponse:
      type: object
      properties:
        id:
          type: string
          description: Mã định danh yêu cầu duy nhất.
          example: 550e8400-e29b-41d4-a716-446655440000
        success:
          type: boolean
          description: Liệu việc xây dựng giao dịch có thành công hay không.
          example: true
        version:
          type: string
          example: V1
        data:
          type: object
          description: Dữ liệu giao dịch.
          properties:
            transaction:
              type: string
              description: Giao dịch versioned được mã hóa Base64 (sẵn sàng ký).
            addressLookupTableAddresses:
              type: array
              description: Địa chỉ bảng tra cứu địa chỉ (nếu txVersion=V0).
              items:
                type: string
    ErrorResponse:
      type: object
      properties:
        id:
          type: string
          description: Mã định danh yêu cầu duy nhất.
        success:
          type: boolean
          example: false
        version:
          type: string
          example: V1
        msg:
          type: string
          description: 'Mã tin nhắn lỗi (ví dụ: REQ_SLIPPAGE_BPS_ERROR, REQ_WALLET_ERROR).'

````