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

# Get block template

> Gets a block template for mining purposes.

## Cost

This endpoint costs **0.1 RU** (Request Units) per call.


## OpenAPI

````yaml POST /v1/rpc/getBlockTemplate
openapi: 3.0.0
info:
  title: Kaspa Developer Platform (KDP) API
  description: >-
    A high-performance REST API providing real-time and historical data from the
    Kaspa blockchain
  version: '1.0'
  contact: {}
servers:
  - url: https://api.kas.fyi
    description: Mainnet API
security: []
tags:
  - name: Address
    description: Operations related to Kaspa addresses
  - name: Block
    description: Operations related to Kaspa blocks
  - name: Transaction
    description: Operations related to Kaspa transactions
  - name: Token
    description: Operations related to KRC20 tokens
  - name: Kaspa Node RPC Proxy
    description: Direct proxy to Kaspa node RPC methods
paths:
  /v1/rpc/getBlockTemplate:
    post:
      tags:
        - Kaspa Node RPC Proxy
      summary: Get block template
      description: Gets a block template for mining purposes.
      operationId: RpcController_getBlockTemplate
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RpcGetBlockTemplateRequestDto'
      responses:
        '200':
          description: Block template retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RpcGetBlockTemplateResponseDto'
      security:
        - x-api-key: []
components:
  schemas:
    RpcGetBlockTemplateRequestDto:
      type: object
      properties:
        payAddress:
          type: string
          description: Pay address for the block template
          example: kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz
        extraData:
          type: string
          description: Optional extra data as string or byte array
          example: Extra block data
      required:
        - payAddress
    RpcGetBlockTemplateResponseDto:
      type: object
      properties:
        block:
          description: Raw block template for mining
          allOf:
            - $ref: '#/components/schemas/RpcRawBlockDto'
      required:
        - block
    RpcRawBlockDto:
      type: object
      properties:
        header:
          description: Raw block header (without cached hash)
          allOf:
            - $ref: '#/components/schemas/RpcRawHeaderDto'
        transactions:
          description: Transactions in this block
          type: array
          items:
            $ref: '#/components/schemas/RpcSubmitTransactionDto'
      required:
        - header
        - transactions
    RpcRawHeaderDto:
      type: object
      properties:
        version:
          type: number
          description: Block version
          example: 1
        parentsByLevel:
          description: Parents by level
          example:
            - - 0x1234567890abcdef...
            - - 0x9876543210fedcba...
          type: array
          items:
            type: string
        hashMerkleRoot:
          type: string
          description: Hash merkle root
          example: 34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6
        acceptedIdMerkleRoot:
          type: string
          description: Accepted ID merkle root
          example: 34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6
        utxoCommitment:
          type: string
          description: UTXO commitment
          example: 34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6
        timestamp:
          format: int64
          type: integer
          description: Block timestamp
          example: '1638360000000'
        bits:
          type: number
          description: Difficulty bits
          example: 393216
        nonce:
          format: int64
          type: integer
          description: Nonce
          example: '12345678901234567890'
        daaScore:
          format: int64
          type: integer
          description: DAA score
          example: '1234567'
        blueWork:
          type: object
          description: Blue work
          example: '123456789012345'
        blueScore:
          format: int64
          type: integer
          description: Blue score
          example: '1234567'
        pruningPoint:
          type: string
          description: Pruning point hash
          example: 34e9538fd3225652553930657c3d767d5ccab0fcd545038a69c202e45929dcd6
      required:
        - version
        - parentsByLevel
        - hashMerkleRoot
        - acceptedIdMerkleRoot
        - utxoCommitment
        - timestamp
        - bits
        - nonce
        - daaScore
        - blueWork
        - blueScore
        - pruningPoint
    RpcSubmitTransactionDto:
      type: object
      properties:
        version:
          type: number
          description: Transaction version
          example: 0
        inputs:
          description: Transaction inputs
          type: array
          items:
            $ref: '#/components/schemas/RpcSubmitTransactionInputDto'
        outputs:
          description: Transaction outputs
          type: array
          items:
            $ref: '#/components/schemas/RpcSubmitTransactionOutputDto'
        lockTime:
          type: number
          description: Lock time
          example: 0
        subnetworkId:
          type: string
          description: Subnetwork ID
          example: '0000000000000000000000000000000000000000'
        gas:
          type: string
          description: Gas limit (as string)
          example: '0'
        payload:
          type: string
          description: Transaction payload in hex
          example: ''
      required:
        - version
        - inputs
        - outputs
        - lockTime
        - subnetworkId
        - gas
    RpcSubmitTransactionInputDto:
      type: object
      properties:
        previousOutpoint:
          description: Previous transaction outpoint
          allOf:
            - $ref: '#/components/schemas/RpcSubmitTransactionOutpointDto'
        signatureScript:
          type: string
          description: Signature script in hex format
          example: >-
            4123c94e322fd98ce4ba8b2e33b47f2984a2f741ecfea6fb48eb90d209a46b9d58639888a1575a717cb243b006edd720a7153e9a7e63f4539958d0a44eea8bfa9f01
        sequence:
          type: number
          description: Input sequence number
          example: 0
        sigOpCount:
          type: number
          description: Number of signature operations
          example: 1
      required:
        - previousOutpoint
        - signatureScript
        - sequence
        - sigOpCount
    RpcSubmitTransactionOutputDto:
      type: object
      properties:
        value:
          type: string
          description: Output value in SOMPI (as string)
          example: '100000'
        scriptPublicKey:
          description: Script public key
          allOf:
            - $ref: '#/components/schemas/RpcSubmitScriptPublicKeyDto'
      required:
        - value
        - scriptPublicKey
    RpcSubmitTransactionOutpointDto:
      type: object
      properties:
        transactionId:
          type: string
          description: Transaction ID
          example: fa99f98b8e9b0758100d181eccb35a4c053b8265eccb5a89aadd794e087d9820
        index:
          type: number
          description: Output index
          example: 1
      required:
        - transactionId
        - index
    RpcSubmitScriptPublicKeyDto:
      type: object
      properties:
        version:
          type: number
          description: Script version
          example: 0
        script:
          type: string
          description: Script in hex format
          example: 208b42bec57f9a538f740b067f947a5b29e04043218a37ff1fa7fb5ee850fd3fd3ac
      required:
        - version
        - script
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key required for authentication. Get your API key at
        https://developer.kas.fyi

````