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

# Create Buy Transaction

> Generate a Base64 encoded buy transaction for a standard pool.

**Flow:** First call `/quote/buy` to get a quote, then pass the `quote_response` here to build the transaction. The returned transaction must be signed by the payer and submitted to the Solana network.

The transaction includes: compute budget instructions, wSOL wrapping, token ATA creation (if needed), the buy instruction, and wSOL unwrapping.



## OpenAPI

````yaml /openapi.json post /tx/buy
openapi: 3.1.0
info:
  title: heaven-tx-api
  description: ''
  license:
    name: ''
  version: 0.1.14
servers:
  - url: https://tx.api.heaven.xyz
security: []
tags:
  - name: heaven-api
    description: Heaven API
paths:
  /tx/buy:
    post:
      tags:
        - Standard Pool API
      summary: Create Buy Transaction
      description: >-
        Generate a Base64 encoded buy transaction for a standard pool.


        **Flow:** First call `/quote/buy` to get a quote, then pass the
        `quote_response` here to build the transaction. The returned transaction
        must be signed by the payer and submitted to the Solana network.


        The transaction includes: compute budget instructions, wSOL wrapping,
        token ATA creation (if needed), the buy instruction, and wSOL
        unwrapping.
      operationId: create_buy_tx
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBuyTxRequest'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateBuyTxResponse'
components:
  schemas:
    CreateBuyTxRequest:
      type: object
      required:
        - payer
        - quote_response
        - encoded_user_defined_event_data
      properties:
        compute_unit_limit:
          type:
            - integer
            - 'null'
          description: Maximum compute units to use for the transaction
          default: 200000
          minimum: 0
        compute_unit_price:
          type:
            - integer
            - 'null'
          description: Price per compute unit in micro-lamports
          default: 40000000
          minimum: 0
        encoded_user_defined_event_data:
          type: string
          description: >-
            Arbitrary user-defined event data to include in the transaction for
            tracking purposes
          example: ''
        payer:
          type: string
          description: Public key of the account that will pay for the transaction
          example: GrX8TXKsPNokXKzfUg7tYmWs6MLhNseScc4PnzyiqpP7
        quote_response:
          $ref: '#/components/schemas/QuoteBuyResponse'
          description: >-
            The full quote response object from the Quote Buy endpoint. Pass the
            entire response without modification.
        source:
          type:
            - string
            - 'null'
          description: >-
            Public key of the token account to debit tokens from. If not
            provided, the payer's associated token account will be used.
          example: GrX8TXKsPNokXKzfUg7tYmWs6MLhNseScc4PnzyiqpP7
    CreateBuyTxResponse:
      type: object
      required:
        - tx
      properties:
        tx:
          type: string
          description: >-
            A Base64 encoded transaction that can be signed and submitted to the
            Solana network.
          example: BASE64_ENCODED_TRANSACTION
    QuoteBuyResponse:
      type: object
      required:
        - max_sol_spend
        - max_lamport_spend
        - minimum_out
        - minimum_out_ui
        - config_version
        - mint
        - program_id
        - slippage_bps
      properties:
        config_version:
          type: integer
          format: int32
          minimum: 0
          description: Protocol config version used for the quote.
        max_lamport_spend:
          type: integer
          description: Maximum amount of lamports to spend for the buy operation
          minimum: 0
        max_sol_spend:
          type: number
          description: Maximum amount of SOL to spend for the buy operation
        minimum_out:
          type: integer
          description: Minimum amount of tokens to receive from the buy operation
          minimum: 0
        minimum_out_ui:
          type: number
          description: >-
            Minimum amount of tokens to receive from the buy operation in UI
            format
        mint:
          type: string
          description: Mint address of the token being bought.
        program_id:
          type: string
          description: Heaven DEX program ID used.
        slippage_bps:
          type: integer
          format: int64
          minimum: 0
          description: Slippage tolerance applied (basis points).

````