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

v0 source realm

Package million is a pay-per-pixel collaborative canvas: anyone can paint any pixel of a Width x Height grid in one o...

Readme View source

million

Realm gno.land/r/g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj/million/v0: a 1250 x 800 (one million pixels, 16:10) pay-per-pixel canvas built on gno.land/p/g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj/canvas/v0.

Paint from the CLI:

1gnokey maketx call -pkgpath gno.land/r/g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj/million/v0 -func PaintBatch \
2  -args "10,10,6;11,10,6" -send 100000ugnot \
3  -gas-fee 1000000ugnot -gas-wanted 5000000 -broadcast -chainid dev -remote 127.0.0.1:26657 <key>

The amount sent must equal Price() times the number of pixels, and the call must come directly from a user transaction. Payments are forwarded to the admin wallet (Owner()) as they arrive; the admin paints for free and can SetPrice, SetMaxBatch, Withdraw and TransferOwnership (all params are owner-settable at runtime). Read functions used by clients: GetWidth, GetHeight, Price, Palette, MaxBatchSize, Painted, Pixel(x, y), Rows(from, to), Version(), DirtyRows(since).

Version() counts successful paint calls and DirtyRows(since) lists the rows touched after that version, so clients fetch only what changed.

Overview

Package million is a pay-per-pixel collaborative canvas: anyone can paint any pixel of a Width x Height grid in one of 15 colors by sending exactly Price() ugnot per pixel along with the call. Pixels can be repainted by anyone, for the same price. Payments are forwarded to the admin wallet as they arrive, and the admin paints for free.

The grid logic lives in gno.land/p/g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj/canvas/v0; this realm adds the payment guard, the owner controls and the read API used by the web client.

Constants 2

const Width, Height, DefaultMaxBatch, HardMaxBatch, DefaultPrice, DefaultAdmin, Denom

 1const (
 2	// Width and Height are fixed for the life of this version: changing
 3	// them would change the storage layout, so it means a new /vN.
 4	// 1250 x 800 is one million pixels in a 16:10 laptop aspect ratio.
 5	Width  = 1250
 6	Height = 800
 7
 8	// DefaultMaxBatch bounds a single PaintBatch call so one tx cannot blow
 9	// the block gas limit or overflow the price arithmetic. The owner can
10	// change it at runtime with SetMaxBatch, up to HardMaxBatch.
11	DefaultMaxBatch = 5000
12	HardMaxBatch    = 20000
13
14	// DefaultPrice is the initial price per pixel, in ugnot (0.05 GNOT).
15	DefaultPrice int64 = 50_000
16
17	// DefaultAdmin receives every payment, paints for free and holds the
18	// owner controls. Change it before deploying; TransferOwnership moves
19	// it afterwards.
20	DefaultAdmin = "g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj"
21
22	Denom = "ugnot"
23)
source

const Realm

1const Realm = "/r/g19t6f4f4ptt3m949jznalfsx2h8aj696llul0nj/million/v0"
source

Realm is this realm's gnoweb path.

Functions 19

func DirtyRows

Action
1func DirtyRows(since int64) string
source

DirtyRows lists the rows painted after version `since`, as "y,y,y" in ascending order. DirtyRows(0) is every row that was ever painted, which is all a fresh client needs to load: the others are blank.

func Paint

crossing Action
1func Paint(cur realm, x, y, color int)
source

Paint colors one pixel. Send exactly Price() ugnot (nothing for the admin).

func PaintBatch

crossing Action
1func PaintBatch(cur realm, pixels string)
source

PaintBatch colors up to MaxBatchSize() pixels in one call. The argument is "x,y,color;x,y,color;...". Send exactly Price() * count ugnot (nothing for the admin).

func Palette

Action
1func Palette() string
source

Palette returns the 16 palette colors as comma-separated CSS hex values, index 0 being the blank color.

func Pixel

Action
1func Pixel(x, y int) int
source

Pixel returns the color index at (x, y); 0 means never painted.

func Render

1func Render(_ string) string
source

Render shows the game stats on gnoweb. The path is ignored.

func Rows

Action
1func Rows(from, to int) string
source

Rows returns rows [from, to) as one hex digit per pixel, Width digits per row, with no separators. Clients page through the grid with it.

func SetMaxBatch

crossing Action
1func SetMaxBatch(cur realm, n int)
source

SetMaxBatch changes the maximum pixels per PaintBatch call, 1..HardMaxBatch.

func SetPrice

crossing Action
1func SetPrice(cur realm, ugnot int64)
source

SetPrice changes the price per pixel, in ugnot. Zero makes painting free for everyone.

func TransferOwnership

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

TransferOwnership hands the admin role (payments, free painting and the owner controls) to newOwner.

func Version

Action
1func Version() int64
source

Version is the number of successful paint calls so far. Clients remember it and ask DirtyRows for what changed since.

func Withdraw

crossing Action
1func Withdraw(cur realm, to address, amount int64)
source

Withdraw sends amount ugnot held by the realm to the given address. Payments are forwarded on arrival, so this only matters for coins sent to the realm outside of a paint call.

Imports 7

Source Files 4