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

# Reading the tier

> How your script reads which tier a buyer paid for.

When a buyer's key validates, Sirius injects a `Sirius` global before your code runs. Read it to branch on what they own.

## The Sirius global

```lua theme={null}
getgenv().Sirius = {
    Tier = {
        id = "gold",
        name = "Gold Tier"
    },
    Source = "whitelist",
    ExpiresAt = nil
}
```

| Field       | Description                                                         |
| ----------- | ------------------------------------------------------------------- |
| `Tier.id`   | The permanent slug from the product. Branch on this.                |
| `Tier.name` | Display name. Safe for UI.                                          |
| `Source`    | `"whitelist"` for paid keys, `"checkpoint"` for free ad-gated keys. |
| `ExpiresAt` | Unix seconds for subscriptions, `nil` for permanent keys.           |

## Branching

```lua theme={null}
local tier = getgenv().Sirius and getgenv().Sirius.Tier
local tierId = tier and tier.id or "free"

if tierId == "gold" then
    enableGoldFeatures()
elseif tierId == "silver" then
    enableSilverFeatures()
else
    enableBasicFeatures()
end
```

Always default to `"free"` when the global is missing — the script might be running outside a key gate.

## Trust the global once

The buyer's executor controls the runtime. They can overwrite `getgenv().Sirius` after your script loads. Read it once at the top of your script and cache it.

```lua theme={null}
-- Top of file, before any other code
local SIRIUS_TIER = (getgenv().Sirius and getgenv().Sirius.Tier and getgenv().Sirius.Tier.id) or "free"

-- Use SIRIUS_TIER everywhere; never re-read getgenv().Sirius
```

The tier id and watermark are also baked into the source itself, so leaked scripts trace back regardless of runtime tampering.
