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

pixels source realm

Package pixels is the real, permanent GNO Pixels realm -- gno.land/r/pixelsandbox (this project's earlier scratch dep...

Overview

Package pixels is the real, permanent GNO Pixels realm -- gno.land/r/pixelsandbox (this project's earlier scratch deployment, never redeployable in place once live) was always the deliberately generic placeholder name described in this project's own README, kept around exactly so the design could keep changing without colliding with whatever this real deployment ended up being called.

Expandable bounds instead of a fixed size, per-pixel provenance (who placed it, at what block), and an owner-gated import hook for migrating the scratch realm's already-placed pixels into this one.

Constants 1

const InitialMinX, InitialMaxX, InitialMinY, InitialMaxY, MaxBoardDim, ExpandStep, ExpandThresholdPercent, CooldownBlocks, cellPx, FeePerPixelUgnot, VandalismFeeUgnot, MaxBulkPixels, MaxCommunityDesignPixels, MaxCommunityDesignNameLen

 1const (
 2	// Starts at the full MaxBoardDim from genesis rather than the
 3	// original 64x64-then-auto-expand design -- with real community
 4	// placements landing right at the logo's edges as it neared
 5	// completion, waiting for the 80%-occupancy trigger would mean
 6	// people cramming free-form art tight against it first. Centered on
 7	// (31.5, 31.5), the original 64-wide board's own center, so every
 8	// existing target_pattern.js / migrated-pixel coordinate keeps
 9	// exactly the same (x, y) and lands in the same place relative to
10	// the logo, just with far more breathing room around it.
11	InitialMinX, InitialMaxX = int64(-32), int64(95)
12	InitialMinY, InitialMaxY = int64(-32), int64(95)
13
14	MaxBoardDim = 128
15	ExpandStep  = 8
16
17	ExpandThresholdPercent = 80
18
19	CooldownBlocks = 1
20	cellPx         = 8
21
22	// FeePerPixelUgnot is charged for any placement that doesn't match
23	// the current owner-curated official target (see officialTarget) --
24	// placing toward the official design stays free, everything else
25	// (free-form painting, or bulk-helping finish someone else's custom
26	// canvas) costs this per cell, paid to collectionOwner.
27	FeePerPixelUgnot = 100_000 // 0.1 GNOT
28
29	// VandalismFeeUgnot applies instead of FeePerPixelUgnot when a cell
30	// IS part of the official target area but the caller paints it a
31	// different color than the design calls for -- overwriting/defacing
32	// an in-progress logo cell costs more than painting blank free-form
33	// space, so griefing the logo is strictly more expensive than
34	// helping (free) or painting elsewhere (the normal rate).
35	VandalismFeeUgnot = 1_000_000 // 1 GNOT
36
37	// MaxBulkPixels bounds SetPixels' batch size -- keeps a single
38	// transaction's gas/arg-size reasonable and bounds the worst-case
39	// payment amount a caller has to attach.
40	MaxBulkPixels = 10
41
42	// MaxCommunityDesignPixels bounds a single submitted design -- the
43	// per-byte storage deposit already prices submission naturally, this
44	// is just a hard ceiling against one submission dominating the
45	// realm's storage.
46	MaxCommunityDesignPixels  = 4000
47	MaxCommunityDesignNameLen = 60
48)
source

Functions 29

func ClearOfficialTarget

crossing Action
1func ClearOfficialTarget(cur realm)
source

ClearOfficialTarget wipes the entire free-to-place design -- owner- only. Split out from SetOfficialTarget now that registration is additive, so "start over from nothing" is still possible but isn't the default behavior of every registration call.

func GetCommunityDesign

Action
1func GetCommunityDesign(id string) string
source

GetCommunityDesign returns the raw "x,y,c;x,y,c;..." for one design, or "" if id doesn't exist.

func ListCommunityDesigns

Action
1func ListCommunityDesigns() string
source

ListCommunityDesigns returns "id,name,pixelCount;id,name,pixelCount;..." for every submitted design, in submission order.

func RemoveCommunityDesign

crossing Action
1func RemoveCommunityDesign(cur realm, id string)
source

RemoveCommunityDesign lets the owner delist a design (offensive name, spam, abuse of the free-submission path) -- owner-only moderation hook. Pixels already placed toward it stay exactly as painted (this only removes it from ListCommunityDesigns/GetCommunityDesign, it doesn't touch the grid), and the id is never reused.

func SetOfficialTarget

crossing Action
1func SetOfficialTarget(cur realm, encoded string)
source

SetOfficialTarget merges entries into the free-to-place design -- owner-only, additive rather than replacing. Registering the full ~800-cell logo costs real storage deposit (measured ~0.19 GNOT/cell on testnet), enough that doing it in one transaction risks needing the whole amount upfront in a single call; additive means it can be split across as many affordable calls as needed, called repeatedly over time. encoded is "x,y,c;x,y,c;...", matching the CSV-ish convention already used by TopPlacers. Calling this with a coordinate already in the target just overwrites that one entry's color, same as you'd expect.

func SetPixels

crossing Action
1func SetPixels(cur realm, encoded string)
source

SetPixels places up to MaxBulkPixels pixels in one transaction. encoded is "x,y,c;x,y,c;...". Cooldown is checked and updated once for the whole batch rather than per pixel -- SetPixel's own per-call cooldown would otherwise reject every entry after the first within the same block, since they all execute in the same transaction/ height. Fee is the sum of pixelFee(x, y, c) across every entry, collected as one payment.

func SubmitCommunityDesign

crossing Action
1func SubmitCommunityDesign(cur realm, name string, encoded string) string
source

SubmitCommunityDesign registers a new community-submitted design -- anyone can call this, not just the owner. encoded is "x,y,c;x,y,c;...", already in absolute board coordinates (the submitter positions it client-side before submitting). Placing any of these cells still costs the normal FeePerPixelUgnot, same as any other free-form cell -- this just makes the design's shape and position visible on-chain so other visitors' browsers can render a progress bar for it and help fill it in, the same way everyone already helps finish the owner-curated logo.

func TopPlacers

Action
1func TopPlacers(n int64) string
source

TopPlacers returns up to n "address,count" pairs, semicolon-separated, sorted by count descending -- the leaderboard. Iterated fresh on every call rather than kept pre-sorted, since contributor counts are small enough (real participants, not per-pixel) for a plain insertion sort to be cheap regardless of how large the canvas itself grows. Gno's "sort" package predates Go's generics-based sort.Slice, so this is hand-rolled rather than using sort.Interface for a one-off local type.

Imports 9

Source Files 2