Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

upload source realm

Package upload is the engine/v2 adapter for uploaded collections (docs/uploaded-collections.md §5.3, §7–§10, §0a; mai...

Overview

Package upload is the engine/v2 adapter for uploaded collections (docs/uploaded-collections.md §5.3, §7–§10, §0a; mainnet plan §2.3, WP-F). Core knows it as a media engine (Manifest.Kind "media"): each collection's params name one sealed asset store ("store:<id>", r/…/assets/v1) and Bind locks that store to the collection while it is a Draft. After the reveal every token's art is the artwork of the slot a salt-keyed permutation gives it, and core itself serves it:

  • core.TokenURI = Media(in): the checked on-chain file as a data URI (raster or SVG) or "ipfs://<CIDv1>" (I-15);
  • core.TokenCard = Render(in): the on-chain SVG itself, or a certificate card for raster/IPFS art (SVG-only clients, gnoweb);
  • core.TokenTraits = Traits(in) with the creator's real trait names, checked by core against TraitTypes(params) (stored per collection);
  • core.Launch runs CheckLaunch (T14: no launch without a bound store).

What holds, and why:

  • art theft (T1): ValidateParams accepts a store only when its owner signs the Create tx; Bind needs caller == collection creator == store owner, from a wallet;
  • no swap after sale (T2): stores are sealed before Bind and never change; params are fixed by core; Bind and Unbind run only while core says Draft, i.e. before any token was ever minted;
  • one collection per store (T3); slots == maxSupply (T13), checked at Bind and again by CheckLaunch;
  • unbound launch (T14): CheckLaunch refuses a collection whose store is not bound to it, so core never launches one (closes the residual of docs/uploaded-collections.md T14 for every client);
  • snipe resistance (T4/T5): before Final core shows its placeholder and never calls Media/Render/Traits; every read here checks Final too; the assignment needs the final salt (core.Salt); Media/Render/Traits answer core's real call only (CollectionID, params and seed must match core's), so RenderWith/TraitsWith (CollectionID "0") always get the generic card and no traits;
  • SA-L5: core's static payee deny list refuses this realm and assets/v1 as payees and treasury at Create and SetPayees (also after Final);
  • I-12/I-16: Media, Render, Traits, TraitTypes, CheckLaunch and ValidateParams only read; Bind, Unbind and Settle are crossing functions; there is no exported non-crossing mutator.

The adapter is stateful by design (bindings and cached keys), declares Living false, takes no fee (D3) and holds no coins.

Constants 6

const TraitTier, TraitEdition, TraitStorage

1const (
2	TraitTier    = "Tier"
3	TraitEdition = "Edition"
4	TraitStorage = "Storage"
5)
source

Trait names the adapter adds itself (assets/v1 reserves them, so a creator's trait type can never collide). A collection's trait list is TraitTypes(params): Tier (if the store has tiers), the creator's types in store order, Edition (if an artwork has editions), Storage.

const MaxTraitsBatch, MaxTraitJSONLists, MaxTraitLists, MaxTraitCounts

1const (
2	MaxTraitsBatch    = 20  // JSON
3	MaxTraitJSONLists = 20  // typed, JSON per token (reader.Cards)
4	MaxTraitLists     = 250 // typed
5	MaxTraitCounts    = 200 // TraitCounts (reader.TraitCounts)
6)
source

MaxTraitsBatch bounds TraitsBatch (JSON); MaxTraitLists bounds the typed TraitLists. Both compute the permutation key once per call (§0a), never per token. Sized so the worst store the asset limits allow stays <= 1B test gas per call (review UP-M1; zz_worst_gas_test.gno).

const CardFingerprint

1const CardFingerprint = "0e414b46db68c64891aadfb4e1fc18ef63d9711907538b659b61b41c7d34efd1"
source

CardFingerprint = sha256(cardSVG) = the engine's sample fingerprint (TestCardFingerprint checks it against core's registration).

const EngineVersion

1const EngineVersion = "2.0.0"
source

EngineVersion is Manifest().Version.

const FeeBps

1const FeeBps = 0
source

FeeBps is the engine-author fee (D3: none; fixed forever at Register).

Functions 24

func Assignment

Action
1func Assignment(cid, tid string) (ready bool, slot, edition int64, a media.Artwork)
source

Assignment is the typed TokenArtwork for other realms (gallery): ready is false before Final or when the collection is not ready; a is a copy.

func Bind

crossing Action
1func Bind(cur realm, cid string)
source

Bind locks the collection's store (its params "store:<id>") to the collection. Caller == core creator == store owner, from a wallet; core state Draft; the collection uses this engine; the store is sealed and not bound elsewhere; maxSupply == the store's slots. cid may be "<cid>" or "c/<cid>"; the binding is kept under core's bare id. Event StoreBound{store, cid}.

func IsUpload

Action
1func IsUpload(cid string) bool
source

IsUpload reports whether cid's engine is this adapter.

func Readiness

Action
1func Readiness(cid string) (ready bool, reason, store, badge string)
source

Readiness is the typed Status for other realms.

func Register

crossing Action
1func Register(cur realm) string
source

Register is an explicit call (not init: under the inert package policy init runs in the approver's tx). The card's fingerprint is reserved in core's source for the platform author, so only that key can sign it.

func Render

1func Render(path string) string
source

Render stays minimal; uploaded collections are browsed in the gallery.

func SelfPath

Action
1func SelfPath() string
source

SelfPath and AssetsPath are the engine id and the store realm it reads.

func SetComposition

Action
1func SetComposition(cid string) string
source

SetComposition is {collection, store, ready, reason, set}, set = assets.Composition of the collection's store: slots per tier and per trait value over the planned set (public and fixed before the sale, D8).

func Settle

crossing Action
1func Settle(cur realm, cid string)
source

Settle caches the salt and permutation key once the collection is Final. Anyone may call it; it is deterministic (the salt is final) and idempotent, and it only saves read gas: the lazy path computes the same key. Event Settled{cid, key} (first call only).

func Status

Action
1func Status(cid string) string
source

Status is {cid, upload, state, store, bound, ready, reason, badge, settled, maxSupply, slots}. The frontend shows the mint UI only when ready (T14).

func StorageBadge

Action
1func StorageBadge(cid string) string
source

StorageBadge is "computed" (any other engine), "onchain", "ipfs", "mixed", or "unbound" for an upload collection that is not ready (§9).

func StoreOf

Action
1func StoreOf(cid string) string
source

StoreOf is the store named by cid's params ("" if none).

func TokenArtwork

Action
1func TokenArtwork(cid, tid string) string
source

TokenArtwork is the token's assignment as JSON: {collection, tid, revealed, ready, reason} and, once revealed and ready, {store, artwork, slot, edition, editions, assignment, kind, mime, mimeType, size, sha256, digest, cid, uri, tier, tierSource, title, traits}. uri is "ipfs://<cid>" for IPFS art and "" for on-chain art (read its bytes with TokenImage / TokenURI: base64 of up to 256 KiB is not free).

func TokenImage

Action
1func TokenImage(cid, tid string) string
source

TokenImage is the inline image: core.TokenURI, except "" for IPFS art (never a remote URL); core's placeholder before Final. Panics on an unknown token or a collection of another engine.

func TokenMetadata

Action
1func TokenMetadata(cid, tid string) string
source

TokenMetadata is the upload view of the metadata (§10.2): core's TokenMetadata fields plus image_size and properties (store, artwork, edition, storage, cid, title, tier, tierSource, assignment, fair, mimeVerified). "image" equals core.TokenURI and is written with RawStrField (a data URI / ipfs URI needs no escaping: M-4, the 256 KiB PNG no longer runs out of gas). mimeVerified (UP-I6) is true only for on-chain files, whose type the chain checked; an IPFS file's mime is the creator's claim. Before Final: core's placeholder image and [{Status: Unrevealed}].

func TokenTraitList

Action
1func TokenTraitList(cid, tid string) []engine.Trait
source

TokenTraitList is the typed real-name trait list of one token (a copy).

func TokenTraits

Action
1func TokenTraits(cid, tid string) string
source

TokenTraits is TokenTraitList as [{"trait_type","value"}] JSON.

func TokenURI

Action
1func TokenURI(cid, tid string) (string, error)
source

TokenURI is core.TokenURI of an upload collection (sinopia4: core serves the art through Media): "data:<mime>;base64,…" for on-chain art, "ipfs://<cidv1>" for IPFS art, core's placeholder before Final. Kept for callers of the sinopia3 adapter; read core directly.

func TraitCounts

Action
1func TraitCounts(cid string, offset, limit int64) string
source

TraitCounts is {"n": tokens counted, "counts": {type: {value: count}}} over tokens offset+1 … offset+limit (limit <= MaxTraitCounts, burned skipped), with the creator's real names: Tier, the creator's trait types (store order, values in dictionary order), Edition, Storage. Before Final every token counts as {"Status": "Unrevealed"}, Final but not ready as {"Status": "Not ready"}. One permutation key per call; the counting runs in assets/v1 over integer ids (review UP-M1).

func TraitJSONLists

Action
1func TraitJSONLists(cid string, offset, limit int64) ([]string, []string)
source

TraitJSONLists is TraitLists with each token's traits as a JSON array (the bytes TokenTraits returns), for pages that print them (reader.Cards). limit <= MaxTraitJSONLists.

func TraitLists

Action
1func TraitLists(cid string, offset, limit int64) ([]string, [][]engine.Trait)
source

TraitLists returns, for tokens offset+1 … offset+limit (limit <= MaxTraitLists, burned tokens skipped), the token ids and their real-name traits. The permutation key is computed once per call.

func TraitsBatch

Action
1func TraitsBatch(cid string, offset, limit int64) string
source

TraitsBatch is [{tid, traits:[{trait_type, value}]}] for tokens offset+1 … offset+limit (limit <= MaxTraitsBatch), burned tokens skipped.

func Unbind

crossing Action
1func Unbind(cur realm, cid string)
source

Unbind releases the store while the collection is still a Draft. Creator only. Event StoreUnbound{store, cid}.

Dependencies

Source Files 5