Key Check Library
The Key Check Library is a small Lua module you load at the start of your script to read a key's status. It tells you whether the key is valid, expired, banned, or bound to a different HWID, so you can show a clear message instead of letting the protected loader kick the user silently.
The check is read-only. It never claims the key, binds the HWID, or increments the execution counter. The real security gate is the loader; this library is only the pre-flight.
Example
Paste this at the top of your script. Replace id with the script UUID from the dashboard, and script_key with whatever variable holds the user's key.
-- load the Key Check Library from the SDK subdomainlocal api = loadstring(game:HttpGet("https://sdk.envyauth.my.id/sdk/library.lua"))() -- bind this api instance to your script. required before any check_key or load_script callapi.script_id = "id" -- read-only key check. returns { code, message, data? }. never claims the key or binds HWIDlocal status = api.check_key(script_key) if status.code == "KEY_VALID" then -- format remaining lifetime for the print. auth_expire = 0 means the key is permanent local hours_left = status.data.auth_expire == 0 and "permanent" or math.floor((status.data.auth_expire - os.time()) / 3600) .. "h" print("[EnvyAuth] Key valid. Plan: " .. (status.data.note or "default") .. ". Expires: " .. hours_left) -- hand off to the protected loader. this is the real auth gate api.load_script() elseif status.code == "KEY_HWID_LOCKED" then -- key is bound to a different device. ask the user to reset HWID via the Discord panel warn("[EnvyAuth] This key is bound to a different device. Reset it from the Discord panel.") elseif status.code == "KEY_EXPIRED" then -- key was valid, but its expiry date has passed warn("[EnvyAuth] Your key expired. Renew or purchase a new one.") elseif status.code == "KEY_BANNED" then -- user is blacklisted. status.message already carries the ban reason from the dashboard warn("[EnvyAuth] " .. status.message) elseif status.code == "KEY_INCORRECT" then -- wrong key, wrong script_id, or forged signature warn("[EnvyAuth] Key is invalid. Double-check the key you entered.") else -- REQUEST_FAILED: could not reach the auth server, or the executor lacks HTTP transport warn("[EnvyAuth] Could not reach the auth server. Try again in a moment.")endThe library exposes its surface through a hidden metatable, so the only field you can assign on api is script_id. Set it once before the first check_key call.
api.check_key(key)
Calls the server and returns a status table:
local status = api.check_key(user_key)-- status.code : string-- status.message : string (human-readable, safe to show in-game)-- status.data : table (only present when code is KEY_VALID)The five codes returned by the server:
| Code | Meaning |
|---|---|
KEY_VALID | The key exists, is not banned or expired, and (if the request carried an HWID) is bound to the caller's device. status.data is populated. |
KEY_INCORRECT | The key does not match any whitelist or unused-key entry on this script. Also returned for malformed input, wrong script ID, or a forged request signature, so callers cannot enumerate. |
KEY_EXPIRED | The key was valid but its expiry date has passed. |
KEY_HWID_LOCKED | The key is bound to a different device than the one calling. Tell the user to reset HWID from your Discord panel. |
KEY_BANNED | The user has been blacklisted. The reason from the dashboard's Reason field is appended to status.message. |
On KEY_VALID, status.data contains:
| Field | Type | Meaning |
|---|---|---|
auth_expire | number | Unix timestamp for key expiry. 0 means permanent. Subtract os.time() for seconds remaining. |
total_executions | number | How many times this key has executed the script. |
note | string | nil | The internal note attached to the key on the dashboard. Useful for distinguishing plan tiers ("Premium", "Ad Reward"). |
hwid_locked | boolean | True when the key is bound to a specific device. |
One client-side failure code is returned without talking to the server:
| Code | Meaning |
|---|---|
REQUEST_FAILED | The executor's HTTP transport is unavailable, the network call threw, the response was non-JSON, or api.script_id was not set. Treat this as "could not reach the server" and let the user retry. |
The HTTP response is always 200 (except for rate limits), so game:HttpGet-based callers do not throw on an error code.
api.load_script()
Once check_key returns KEY_VALID, call api.load_script() to fetch and execute the protected loader:
if status.code == "KEY_VALID" then api.load_script()endapi.load_script() raises an error if api.script_id was not set.
When not to use it
This library is a pre-flight, not a security boundary. The loader still does its own full key validation, so if you skip api.check_key() and call api.load_script() directly, your script still works; you just lose the friendly error path.
The library code is public, so anything it returns (key validity, expiry, the note field) can be observed by the user. Do not put confidential data in the key's note.