ALX Protocol reputation determines how much weight a Knowledge Block’s on-chain history carries in payout computation and access control. The on-chain contract (Documentation Index
Fetch the complete documentation index at: https://docs.xandrlabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
ReputationLogic.sol) produces an integer score from 0 to 1000 based on query volume and endorsements. Your SDK translates that integer into a floating-point reputation score (rs) and applies freshness decay before computing a payout. All functions are exported from @alx/protocol/economics.
Constants
| Constant | Value | Description |
|---|---|---|
RS_MIN | 0.01 | Minimum normalized reputation score. Non-zero so that new KBs with no history remain discoverable and earn a minimal payout. |
RS_MAX | 3 | Maximum normalized reputation score. The top-tier KB earns 3× the base payout. |
HALF_LIFE_DAYS | 30 | Freshness half-life in days. A KB published 30 days ago has a freshness multiplier of 0.5. |
On-chain reputation formula
The reference contract derives the integer score usingReputationLogic.sol:
min(500, 500) + min(100, 100) = 600. You pass this integer to normalizeOnChainScore to get a protocol-usable rs.
Tier thresholds
Tier access gates which queries a KB is eligible to serve. You check tier eligibility withmeetsTier.
| Tier | rs threshold | Access |
|---|---|---|
| 0 | >= 0 | Open — all KBs qualify regardless of reputation |
| 1 | >= 0.5 | Verified — requires modest query history |
| 2 | >= 1.0 | Premium — requires sustained query volume or endorsements |
| 3 | >= 2.0 | Restricted — high-reputation KBs only |
Functions
normalizeOnChainScore
Converts the raw on-chain reputation integer (0–1000) to a normalized float in [RS_MIN, RS_MAX]. You call this immediately after reading the score from the contract or subgraph.
RS_MIN + (score / 1000) × (RS_MAX - RS_MIN)
Input values outside [0, 1000] are clamped before normalization.
On-chain reputation integer produced by
ReputationLogic.sol. Valid range is 0–1000. Values outside this range are clamped.Normalized reputation score in
[0.01, 3]. A score of 0 maps to 0.01; a score of 1000 maps to 3.freshnessMultiplier
Computes the exponential decay multiplier for a KB based on how long ago it was published. More recently published KBs receive a higher multiplier and therefore a higher payout.
0.5 ^ (daysAgo / HALF_LIFE_DAYS)
A KB published today returns 1.0. A KB published 30 days ago returns 0.5. A KB published 60 days ago returns 0.25. The multiplier approaches but never reaches 0 for very old KBs.
If
isoDate is in the future (relative to the current clock), the function returns 1.0 rather than a value greater than 1.ISO-8601 publication date of the Knowledge Block (e.g.
"2026-03-01T00:00:00.000Z"). The function parses this with new Date(), so any valid ISO-8601 string is accepted.Freshness multiplier in
(0, 1]. Returns exactly 1 when daysAgo <= 0.meetsTier
Returns true if the given reputation score meets or exceeds the threshold for the requested tier. Use this before serving a query to enforce access control.
Normalized reputation score in
[RS_MIN, RS_MAX]. Pass the output of normalizeOnChainScore or clampRS.Integer tier level
0–3. Tier 0 always returns true. An unknown tier (outside 0–3) returns true because the threshold lookup falls back to 0.true if rs meets the tier threshold; false otherwise.