Trait Randomization
Traits can be common, uncommon, rare, epic, or legendary. For each category, we spin a deterministic on-chain wheel using the core contract’s per-auction seed.- Seed source:
core.getAuctionSeed(auctionId)returns a per‑auction seed derived in the core contract from chain data. getTrait(category, auctionId):- Sums
weightacross all traits incategory. - Computes
rand = H(category, auctionId, seed) % totalWeight. - Scans cumulatively over traits; the bucket where
rand < accis the selected trait name.
- Sums
- Given the same
auctionIdand trait table, selection is reproducible across nodes and time. That means the artwork for an auction is fixed once the seed is set for a given auction in the core contract.
Layer Retrieval
The sameauctionId + same trait tables = the same result forever. Everyone renders the same art because everything about the brew lives on-chain.
getSVGFragment(category, traitName): Looks up the stored SVG fragment string for the named trait.getTraits(auctionId): Convenience that resolves the selected trait names for each category in canonical order (Background,Brew,Mug,Top).
SVG Composition (The Image Itself)
The renderer stitches the SVG, Base64-encodes it, and serves it inside the token’stokenURI as a data URI—no IPFS pins to rot, no servers to trust. Metadata includes the four trait names so marketplaces can show attributes cleanly.
buildSVG(auctionId):- Starts with an
<svg>root sized1080×1080. - For each category in
categoriesorder, resolves the chosen name withgetTraitand fetches its fragment withgetSVGFragment. - Concatenates fragments in order to form a single SVG document.
- Appends the closing
</svg>tag and returns the complete image string.
- Starts with an
Layering matters: The array order is the z‑order. Background is written first, then Brew, then Mug, then Top.