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

# Get a polymorphic Merkle multiproof for fixture statistics

> This endpoint provides a cryptographic proof for up to 5 statistics within a single scores update.
The TxODDS Oracle data is structured in a three-level Merkle hierarchy:

* A main batch contains summaries for multiple fixtures.
* Each fixture summary is the root of a sub-tree of all score update events for that fixture.
* Each score update event combines an R1 Merkle sub-tree of non-zero statistics with an R2 zero-mask branch proving zero-valued statistics.

This endpoint automatically detects the underlying Merkle schema of the published batch and returns the full set of proofs needed to connect the requested stats to the main batch root published on-chain.

### Polymorphic Schema Support (V1 and V2)
The response returns a `ScoresStatValidationResponseV4` envelope discriminated by schema version:

* **V1 (Legacy 32-byte zero-mask)**: Non-zero stats are proven via `multiproofHashes` and `leafIndices`, while zero-valued stats include per-leaf R2 `statProof` nodes.
* **V2 (Unified 512-byte zero-mask)**: Non-zero stats are proven via `multiproofHashes` and `leafIndices`, while each leaf carries an `isZero` flag and the payload includes a top-level `rawMask` (`Some` when any requested stat is zero, or `None` when all requested stats are non-zero).

### Request Format
The endpoint requires a comma-separated list of 1 to 5 stat keys in the `statKeys` parameter and returns the matching polymorphic proof payload along with the backend Ed25519 signature over the Borsh-serialized payload hash.

### On-Chain Execution
With the returned data, the user initializes a reusable worker ticket via `validate_fixture_for_tree` and executes `validate_stat_v4` (alongside the Ed25519 signature verification instruction) to evaluate an N-dimensional strategy against the verified statistics.




## OpenAPI

````yaml https://txline.txodds.com/docs/docs.yaml get /api/scores/stat-validation-v4
openapi: 3.1.0
info:
  title: TxLINE off-chain API for the Hybrid on-chain/off-chain TxODDS Data system
  version: 1.5.16
  description: >

    ## Overview


    This API provides access to real-time and historical sports data from the
    **TxLINE on-chain/off-chain Data system**.


    It makes proprietary TxODDS available for any funded blockchain users by
    linking the on-chain `subscribe` transaction by issuing time-limited API
    tokens.

    - The data is canonicalised so that all fixtures, odds, or scores are
    provably identifiable and ordered--confirmed by on-chain cryptographic
    proofs.

    - The data is delivered in a request-response or Server-Sent Events (SSE)
    streaming form.


    Examples of accessing the accompanying on-chain program are available
    publicly at: https://txline.txodds.com/documentation.

    All data returned by the off-chain API is canonicalised such that every
    single record can be cryptographically proven on-chain to be

    part of the unique and consistent dataset generated by the TxODDS Data
    system.


    ## Key features


    * The odds data includes the `Stable Price` demargined prices and
    percentages, currently for key markets in European football (soccer).

    * **Free subscription option that offers World Cup 2026 odds and
    off-the-board signals in real-time sampled every 60 seconds**.

    * **Data access paid for by the TxLINE token tethered to USDT ata rate 1
    USDT = 1_000 TxLINE tokens** The TxLINE utility token can purchased using
    the associated Solana program.

    * **Fine-grained service level selection** The user can list the
    pre-configured **service levels** that either map to pre-defined league
    bundles or allow custom selecting the leagues explicitly.
     The price also depends on the sampling period for the data.
    * **Maximum subscription option that offers all leagues in real-time**.

    * **Historical Snapshots:** Query the latest state of any market at a
    specific point in time.

    * **Historical Updates:** Query the updates for any given key such as
    fixture or market for a given time period.

    * **Live Data Streams:** Real-time, low-latency data feeds using Server-Sent
    Events (SSE).

    * **On-chain Validation:** Retrieve Merkle proofs to cryptographically
    verify data against the on-chain held Merkle roots by calling appropriate
    validate on-chain instructions.


    ## How do the users gain access to off-chain data (see more details and
    examples at: https://github.com/txodds/tx-on-chain)


    1. For paid service tiers, the user purchases TxODDS TxLINE utility tokens
    for USDT at a fixed rate using either a script (e.g., calling
    `purchase_subscription_token_usdt`) or an affiliate website. The tokens are
    deposited into the user's associated token account. (Note: This step is
    skipped for the free World Cup tier).

    2. As a guest, with no prior authentication, the user calls the off-chain
    API at "https://txline.txodds.com/auth/guest/start" (or `txline-dev` for
    DevNet) to obtain an anonymous JWT with Guest claims. **Please note that the
    JWT token has 30 days  expiration so if you are issuing calls to the data
    endpoints beyond 30 days, you should either pre-acquire a new JWT token in
    time before 30 days expire or respond to the returned HTTP 401 code by
    reacquiring a fresh JWT token.**

    3. The user creates, signs, and confirms a Solana transaction to the
    `subscribe` instruction, indicating the duration in weeks (must be a
    multiple of 4 weeks, e.g. 4, 8, 12) and the chosen service level. The user
    explicitly acts as the transaction fee payer. For the free tier, the smart
    contract registers the subscription but charges 0 TxLINE tokens.

    4. The user records the confirmed transaction signature (`txSig`).

    5. The user constructs a strict message binding consisting of the `txSig`, a
    comma-separated list of selected leagues, and the JWT.

    6. The user cryptographically signs this message using their wallet's secret
    key to generate a detached signature, which is then Base64-encoded.

    7. The user activates the subscription with the off-chain server at
    "https://txline.txodds.com/api/token/activate" (or `txline-dev` for DevNet)
    by posting the `txSig`, the Base64 wallet signature, and the selected
    leagues array, using the JWT for authorization.

    8. The off-chain server validates the cryptographic proof and entitlements,
    issuing an appropriate API Token or rejecting the activation with a reason.

    9. The user calls the documented APIs while the subscription is valid,
    supplying both the JWT and the API Token.

    10. Before the subscription expires, the user may call the `subscribe`
    instruction again to extend the validity period (by a multiple of 4 weeks,
    e.g. 4, 8, 12) via the same off-chain activation call. The selected leagues
    can also be amended.

    11. If the previous subscription has expired, the user can activate a new
    API Token by repeating the process.
servers:
  - url: https://txline.txodds.com
    description: Production TxLINE server
  - url: http://txline-dev.txodds.com
    description: Test TxLINE server
security: []
paths:
  /api/scores/stat-validation-v4:
    get:
      tags:
        - Scores
      summary: Get a polymorphic Merkle multiproof for fixture statistics
      description: >
        This endpoint provides a cryptographic proof for up to 5 statistics
        within a single scores update.

        The TxODDS Oracle data is structured in a three-level Merkle hierarchy:


        * A main batch contains summaries for multiple fixtures.

        * Each fixture summary is the root of a sub-tree of all score update
        events for that fixture.

        * Each score update event combines an R1 Merkle sub-tree of non-zero
        statistics with an R2 zero-mask branch proving zero-valued statistics.


        This endpoint automatically detects the underlying Merkle schema of the
        published batch and returns the full set of proofs needed to connect the
        requested stats to the main batch root published on-chain.


        ### Polymorphic Schema Support (V1 and V2)

        The response returns a `ScoresStatValidationResponseV4` envelope
        discriminated by schema version:


        * **V1 (Legacy 32-byte zero-mask)**: Non-zero stats are proven via
        `multiproofHashes` and `leafIndices`, while zero-valued stats include
        per-leaf R2 `statProof` nodes.

        * **V2 (Unified 512-byte zero-mask)**: Non-zero stats are proven via
        `multiproofHashes` and `leafIndices`, while each leaf carries an
        `isZero` flag and the payload includes a top-level `rawMask` (`Some`
        when any requested stat is zero, or `None` when all requested stats are
        non-zero).


        ### Request Format

        The endpoint requires a comma-separated list of 1 to 5 stat keys in the
        `statKeys` parameter and returns the matching polymorphic proof payload
        along with the backend Ed25519 signature over the Borsh-serialized
        payload hash.


        ### On-Chain Execution

        With the returned data, the user initializes a reusable worker ticket
        via `validate_fixture_for_tree` and executes `validate_stat_v4`
        (alongside the Ed25519 signature verification instruction) to evaluate
        an N-dimensional strategy against the verified statistics.
      operationId: getApiScoresStat-validation-v4
      parameters:
        - name: Authorization
          in: header
          description: Bearer token for the user's session JWT.
          required: true
          schema:
            type: string
        - name: X-Api-Token
          in: header
          description: The user's long-lived API token.
          required: true
          schema:
            type: string
        - name: fixtureId
          in: query
          description: The ID of the fixture for the scores event.
          required: true
          schema:
            type: integer
            format: int32
        - name: seq
          in: query
          description: >-
            The sequence number of the specific scores event within the
            fixture's history.
          required: true
          schema:
            type: integer
            format: int32
        - name: statKeys
          in: query
          description: Comma-separated list of 1 to 5 stat keys for multiproof validation.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScoresStatValidationResponseV4'
        '400':
          description: Parameter statKeys must contain between 1 and 5 valid integers
          content:
            text/plain:
              schema:
                type: string
        '401':
          description: 'Authorization failed: Invalid or expired guest JWT'
          content:
            text/plain:
              schema:
                type: string
        '403':
          description: 'Access denied: Invalid API token or insufficient permissions'
          content:
            text/plain:
              schema:
                type: string
        '404':
          description: >-
            Message indicating a valid, processed scores record for the
            requested fixtureId and seq could not be found.
          content:
            text/plain:
              schema:
                type: string
        '500':
          description: Internal server error
          content:
            text/plain:
              schema:
                type: string
      security:
        - httpAuth: []
          apiKeyAuth: []
components:
  schemas:
    ScoresStatValidationResponseV4:
      title: ScoresStatValidationResponseV4
      oneOf:
        - $ref: '#/components/schemas/ScoresStatValidationResponseV4V1'
        - $ref: '#/components/schemas/ScoresStatValidationResponseV4V2'
      discriminator:
        propertyName: version
        mapping:
          v1: '#/components/schemas/ScoresStatValidationResponseV4V1'
          v2: '#/components/schemas/ScoresStatValidationResponseV4V2'
    ScoresStatValidationResponseV4V1:
      title: ScoresStatValidationResponseV4V1
      type: object
      required:
        - payload
        - signature
        - version
      properties:
        payload:
          $ref: '#/components/schemas/ScoresStatValidationV1'
        signature:
          type: string
        version:
          type: string
          const: v1
    ScoresStatValidationResponseV4V2:
      title: ScoresStatValidationResponseV4V2
      type: object
      required:
        - payload
        - signature
        - version
      properties:
        payload:
          $ref: '#/components/schemas/ScoresStatValidationV2'
        signature:
          type: string
        version:
          type: string
          const: v2
    ScoresStatValidationV1:
      title: ScoresStatValidationV1
      type: object
      required:
        - ts
        - summary
        - fixtureProof
        - mainTreeProof
        - eventStatRoot
        - multiproofHashes
      properties:
        ts:
          type: integer
          format: int64
        summary:
          $ref: '#/components/schemas/ScoresBatchSummary'
        fixtureProof:
          $ref: '#/components/schemas/List_ProofNode'
        mainTreeProof:
          $ref: '#/components/schemas/List_ProofNode'
        eventStatRoot:
          type: string
          format: binary
        leaves:
          type: array
          items:
            $ref: '#/components/schemas/StatLeafV1'
        multiproofHashes:
          $ref: '#/components/schemas/List_ProofNode'
        leafIndices:
          type: array
          items:
            type: integer
            format: int32
    ScoresStatValidationV2:
      title: ScoresStatValidationV2
      type: object
      required:
        - ts
        - summary
        - fixtureProof
        - mainTreeProof
        - eventStatRoot
        - multiproofHashes
      properties:
        ts:
          type: integer
          format: int64
        summary:
          $ref: '#/components/schemas/ScoresBatchSummary'
        fixtureProof:
          $ref: '#/components/schemas/List_ProofNode'
        mainTreeProof:
          $ref: '#/components/schemas/List_ProofNode'
        eventStatRoot:
          type: string
          format: binary
        leaves:
          type: array
          items:
            $ref: '#/components/schemas/StatLeafV2'
        multiproofHashes:
          $ref: '#/components/schemas/List_ProofNode'
        leafIndices:
          type: array
          items:
            type: integer
            format: int32
        rawMask:
          type: string
          format: binary
    ScoresBatchSummary:
      title: ScoresBatchSummary
      type: object
      required:
        - FixtureId
        - UpdateStats
        - EventStatsSubTreeRoot
      properties:
        FixtureId:
          type: integer
          format: int32
        UpdateStats:
          $ref: '#/components/schemas/ScoresUpdateStats'
        EventStatsSubTreeRoot:
          type: string
          format: binary
    List_ProofNode:
      title: List_ProofNode
      oneOf:
        - $ref: '#/components/schemas/Nil'
        - type: array
          items:
            $ref: '#/components/schemas/ProofNode'
    StatLeafV1:
      title: StatLeafV1
      type: object
      required:
        - stat
        - statProof
      properties:
        stat:
          $ref: '#/components/schemas/ScoreStat'
        statProof:
          $ref: '#/components/schemas/List_ProofNode'
    StatLeafV2:
      title: StatLeafV2
      type: object
      required:
        - stat
        - isZero
      properties:
        stat:
          $ref: '#/components/schemas/ScoreStat'
        isZero:
          type: boolean
    ScoresUpdateStats:
      title: ScoresUpdateStats
      type: object
      required:
        - UpdateCount
        - MinTimestamp
        - MaxTimestamp
      properties:
        UpdateCount:
          type: integer
          format: int32
        MinTimestamp:
          type: integer
          format: int64
        MaxTimestamp:
          type: integer
          format: int64
    Nil:
      title: Nil
      type: object
    ProofNode:
      title: ProofNode
      type: object
      required:
        - hash
        - isRightSibling
      properties:
        hash:
          type: string
          format: binary
        isRightSibling:
          type: boolean
    ScoreStat:
      title: ScoreStat
      type: object
      required:
        - Key
        - Value
        - Period
      properties:
        Key:
          type: integer
          format: int32
        Value:
          type: integer
          format: int32
        Period:
          type: integer
          format: int32
  securitySchemes:
    httpAuth:
      type: http
      description: User's session JWT.
      scheme: bearer
    apiKeyAuth:
      type: apiKey
      description: The user's long-lived API token, obtained from the activation endpoint.
      name: X-Api-Token
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.