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

# TxLINE integration

> Exact authentication flow, API endpoints, soccer stat keys, terminal phases, and Merkle proof encoding used by Slip.

# TxLINE integration reference

## API origin and authentication

Devnet origin: `https://txline-dev.txodds.com`

| Request                              | Use                                                                       |
| ------------------------------------ | ------------------------------------------------------------------------- |
| `POST /auth/guest/start`             | Obtain the short-lived guest JWT.                                         |
| TxLINE `subscribe(1, 4)` instruction | Activate the free World Cup tier on devnet.                               |
| `POST /api/token/activate`           | Exchange subscription transaction plus wallet signature for an API token. |

Activation signs the exact UTF-8 preimage
`` `${txSig}:${leagues.join(",")}:${jwt}` `` with a detached Ed25519 signature encoded as base64.
With no leagues, the preimage contains `txSig::jwt`.

Authenticated data requests include both headers:

```http theme={null}
Authorization: Bearer <guest-jwt>
X-Api-Token: <activated-api-token>
```

The guest JWT is renewed on HTTP 401. The activated API token is retained.

## Data endpoints used by Slip

| Endpoint                               | Parameters                                         | Consumer       | Purpose                                                               |
| -------------------------------------- | -------------------------------------------------- | -------------- | --------------------------------------------------------------------- |
| `GET /api/fixtures/snapshot`           | `startEpochDay`                                    | Web            | List future non-cancelled fixtures and orient home/away participants. |
| `GET /api/scores/snapshot/{fixtureId}` | `asOf`                                             | Keeper         | Read latest sequence and determine terminal status.                   |
| `GET /api/scores/stat-validation`      | `fixtureId`, `seq`, `statKey`, optional `statKey2` | Keeper and SDK | Retrieve one- or two-stat proof payload for resolution.               |

Slip does not require TxLINE consensus odds. Parimutuel pool balances are the price input.

## Soccer stat keys

`statKey = periodPrefix + baseKey`

| Base key | Meaning           |
| -------: | ----------------- |
|        1 | Home goals        |
|        2 | Away goals        |
|        3 | Home yellow cards |
|        4 | Away yellow cards |
|        5 | Home red cards    |
|        6 | Away red cards    |
|        7 | Home corners      |
|        8 | Away corners      |

| Prefix | Period                 |
| -----: | ---------------------- |
|      0 | Full match             |
|   1000 | First half             |
|   2000 | Half time              |
|   3000 | Second half            |
|   4000 | Extra-time first half  |
|   5000 | Extra-time second half |
|   6000 | Penalty shootout       |
|   7000 | Extra time total       |

Full-match expressions store canonical period tag `100`; period-prefixed expressions store their
prefix. The `ScoreStat.period` inside a proof is different: it is the live match phase at the time of
the record.

## Terminal phases

Settlement accepts `ScoreStat.period` 5, 10, 13, or 100. Values 11 and 12 are live penalty phases,
not terminal states. The keeper also recognizes `action=game_finalised` as terminal.

## Proof payload mapping

`stat-validation` returns number arrays for hashes. The SDK maps the response into `ScoresProof`:

* `statToProve` and `statProof` → `statA`;
* optional `statToProve2` and `statProof2` → `statB`;
* `summary.updateStats` and `summary.eventStatsSubTreeRoot` → the committed fixture summary;
* `subTreeProof` and `mainTreeProof` → the remaining proof segments.

The independent verifier uses SHA-256 with these byte layouts:

```text theme={null}
stat leaf    = sha256(key:u32 LE || value:i32 LE || phase:i32 LE)
fixture leaf = sha256(0x01 || fixture:i64 LE || update_count:i32 LE ||
                      min_ts:i64 LE || max_ts:i64 LE || subtree_root[32])
node         = right sibling ? sha256(current || sibling)
                             : sha256(sibling || current)
```

## Daily roots account

PDA seeds: `["daily_scores_roots", epochDay_u16_le]`, where epoch day derives from the proof's
`summary.updateStats.minTimestamp`, not wall clock.

Account layout: `[8-byte discriminator][u16 epoch day][288 × 32-byte roots]`. Each root represents a
five-minute slot. Slot index is `hour * 12 + floor(minute / 5)`.

## Absence and replay constraints

A zero-valued stat can be absent from a record's tree. An absent leaf cannot produce a valid proof;
Slip treats that as proof unavailability, not as a proved zero.

TxLINE devnet replays fixtures and can rewrite the current virtual five-minute root. The keeper fetches
and submits promptly and uses durable retries. A transient mismatch does not permit an early void.
