Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

memba_arcade_leaderboard_v1 source realm

Package memba\_arcade\_leaderboard\_v1 is the funds-free, verified-score ledger for the Memba arcade (BARRICADE, Spac...

Overview

Package memba_arcade_leaderboard_v1 is the funds-free, verified-score ledger for the Memba arcade (BARRICADE, Space Invaders, and future games — one realm, boards keyed per game slug). Nothing here trusts a client number: an authorized ATTESTER (the backend verifier's key) re-simulates a submitted input log and attests only the reproduced result. The chain stores the attested result plus a commitment to the log (its sha256) — the log itself stays off-chain; "verified, never trustless" is the public contract.

SAFETY: there is NO banker, NO transfer, and NO OriginSend anywhere — the fund-drain risk class does not apply. The only trust boundary is who may attest (owner ∪ the attester allowlist); every write emits an event. Two buckets never mix: the competitive DAILY BOARD (one best entry per address per game per day, shared seed) and personal TRAINING RECEIPTS (practice runs — a verified flex, never ranked).

The game slug is shape-validated only — there is deliberately NO on-chain game registry: the realm is funds-free, so the worst a typo'd slug can do is fragment a board, and the attester (not the player) authors the slug.

Constants 1

const MaxScore, MaxGameLen, MaxStatsLen, ReceiptsCap, ReceiptDailyCap, RequestCap

 1const (
 2	// MaxScore bounds a single attested score — a fat-finger / overflow guard far above any
 3	// reachable sim score (arcade sim scores live in the tens of thousands).
 4	MaxScore = int64(1_000_000_000)
 5	// MaxGameLen bounds the game slug. The slug charset is [a-z0-9-], which EXCLUDES '|' —
 6	// load-bearing: '|' is the composite-key separator in every scoped tree below.
 7	MaxGameLen = 32
 8	// MaxStatsLen bounds the attester-authored per-game stats JSON blob. Ranking never reads
 9	// it; reads only ever emit it JSON-escaped.
10	MaxStatsLen = 256
11	// ReceiptsCap bounds one address's training-receipt ring (oldest evicted first; the ring is
12	// mixed-game, so this is the per-address bound).
13	ReceiptsCap = 100
14	// ReceiptDailyCap bounds how many receipts one address may mint per (game, day) (spam cap).
15	ReceiptDailyCap = 5
16	// RequestCap bounds one address's PENDING receipt requests (fulfilled ones free their slot):
17	// the only unprivileged write path must not grow realm state unboundedly.
18	RequestCap = 8
19)
source

Functions 16

func AcceptOwnership

crossing Action
1func AcceptOwnership(cur realm)
source

AcceptOwnership completes the handoff. Only the staged pendingOwner may call it.

func AddAttester

crossing Action
1func AddAttester(cur realm, addr address)
source

AddAttester allowlists an ADDRESS (the backend verifier's dedicated low-privilege key — never the deploy multisig itself) as an authorized result source. Owner only.

func AttestReceipt

crossing Action
1func AttestReceipt(cur realm, game string, addr address, day, seed string, score, simVersion int64, stateHash, logHash, stats string)
source

AttestReceipt mints a personal training receipt — a verified "I did this run", never ranked. Attester-only; capped per address per (game, day) and ring-capped per address. Fulfills (and clears) a matching player-paid RequestReceipt if one is staged.

func AttestScore

crossing Action
1func AttestScore(cur realm, game string, addr address, day, seed string, score, simVersion int64, stateHash, logHash, stats string)
source

AttestScore writes (or improves) an address's entry on a game's competitive board for a day. Attester-only. The verifier batches a day's results into one multi-msg tx at day close, plus spam-capped singles for the "certify now" flow. Re-attesting the same game/address/day only ever RAISES the score (Second Wind). A log hash already attested for that game-day for a DIFFERENT address is rejected — on a shared daily seed a valid input log is portable, so first-submitter wins (replay-theft defense). `stats` is the attester-authored per-game JSON blob (waves, wins, levels, …) — never ranked, only echoed by reads.

func BoardCount

Action
1func BoardCount(game, day string) int
source

BoardCount returns how many addresses hold an entry on a game's board for a day (O(1)).

func GetBoardJSON

Action
1func GetBoardJSON(game, day string, offset, limit int) string
source

GetBoardJSON returns a page of a game-day's board, rank-ordered, as {"game":…,"day":…,"total":N,"entries":[…]}. Reads sort the day's entries on demand — fine for a testnet-scale board; a rank index (points_v1-style) is the v2 upgrade if daily boards grow past a few thousand entries.

func GetEntryJSON

Action
1func GetEntryJSON(game, day, addr string) string
source

GetEntryJSON returns one address's board entry for a game-day, or "null".

func GetReceiptsJSON

Action
1func GetReceiptsJSON(addr string, offset, limit int) string
source

GetReceiptsJSON returns a page of one address's training receipts (all games, newest first) as {"addr":…,"total":N,"entries":[…]}.

func IsAttester

Action
1func IsAttester(addr string) bool
source

IsAttester reports whether an address is on the attester allowlist.

func Pause

crossing Action
1func Pause(cur realm, state bool)
source

Pause freezes all attestation + receipt requests (reads stay available). Owner only.

func RemoveAttester

crossing Action
1func RemoveAttester(cur realm, addr address)
source

RemoveAttester revokes an attester key. Owner only.

func Render

1func Render(path string) string
source

Render serves a human-readable snapshot: `:board/<game>/YYYY-MM-DD` for a game-day's top entries, `:receipts/<addr>` for an address's latest receipts.

func RequestReceipt

crossing Action
1func RequestReceipt(cur realm, logHash string)
source

RequestReceipt is the player-paid leg: ANY signer stages an on-chain consent + payment anchor for one of their own runs (they pay this call's gas). The backend sees the event, verifies the stored log, and fulfills via AttestReceipt. Self-limiting: each request costs the caller gas, and one key slot per (addr, hash). Hash-scoped and game-agnostic on purpose — the verifier, not the player, decides which game the log replays under.

func TransferOwnership

crossing Action
1func TransferOwnership(cur realm, newOwner address)
source

TransferOwnership stages a new owner; it takes effect only after AcceptOwnership is called BY that address (2-step, so a typo can't brick admin).

Types 1

type Entry

struct
 1type Entry struct {
 2	Addr           address
 3	Game           string // slug, 1..MaxGameLen chars of [a-z0-9-] (never '|', the key separator)
 4	Day            string // YYYY-MM-DD (the shared daily seed's date; receipt = submission day)
 5	Mode           string // "daily" | "practice"
 6	Seed           string
 7	Score          int64  // the ONLY ranked field
 8	Stats          string // compact attester-authored JSON (game-specific; ≤ MaxStatsLen; opaque here)
 9	SimVersion     int64
10	StateHash      string // the sim's canonical terminal-state digest
11	InputLogSha256 string // commitment to the off-chain input log (the proof)
12	AttestedAt     int64  // block height
13}
source

Entry is one attested, verifier-reproduced run result.

Imports 6

Source Files 5