Studio · Write an engine
Publish generative art as code
A Sinopia engine is a small Gno program: a token's seed and the collection's params go in, an SVG and its traits come out. Creators launch collections with it, the chain draws every token, and you earn a fee on every sale.
Two packages
p/…/art/<name>/v1
The art: manifest, params, traits and Render. Pure functions, no state. A p/ package can never change, so every token's art stays fixed forever.
r/…/engines/<name>
The adapter: a zero-size value that implements the interface, your address, your fee and Register. Keep it stateless with no admin; a re-deployable adapter is marked “mutable”.
Start from the template engine Orbits (starter) in the Sinopia source: realms/p/art/starter/v1 and realms/r/engines/starter, with tests and the full guide in docs/engines/write-an-engine.md. Copy, rename, replace the drawing.
The interface
From p/…/sinopia/engine/v2. Input carries the 64-hex seed, the params and the ids; living engines also get heights and transfer counts.
type Engine interface {
Manifest() Manifest // name, version, licence, author, fee, params schema, traits, limits
ValidateParams(params string) error // must accept "" (your defaults)
TraitTypes(params string) []string // static engines: Manifest().TraitTypes
CheckLaunch(cid, params string, maxSupply int64) error // nil for generative engines
Traits(in Input) []Trait // each type at most once
Render(in Input) string // raw SVG; core base64-encodes it
Media(in Input) Media // Media{} for an SVG engine
}Seeded randomness
The pattern every platform engine uses. Draw traits first, then draw the picture from its own stream.
// FNV-1a over the 64-hex seed, then splitmix64: integer math only.
func newRNG(seed string) *rng {
h := uint64(14695981039346656037)
for i := 0; i < len(seed); i++ {
h ^= uint64(seed[i])
h *= 1099511628211
}
return &rng{state: h}
}Rules core checks
Deterministic
Same input, same bytes on every node and in every browser. Integer math only: no floats, no time, no map iteration in output order. All randomness comes from the token's seed.
Draw order is the art
Once collections exist, never reorder or add draws in a published version. Draw the picture from a separate stream so drawing never shifts traits.
Allowlisted SVG
Shapes, paths, gradients, patterns, filters such as feTurbulence, symbol and use. No style blocks, images, scripts, animation, external references or event attributes. Check a render below.
Small and cheap
Every token read runs your Render on chain. Targets the platform's engines meet: SVG ≤ 28 KB, worst TokenURI ≤ 1.0B gas, Register ≤ 350M gas.
Params
"" must be valid and mean your defaults. Accept exactly the canonical JSON Studio writes, and apply a creator's choice after all seed draws so a seed's other traits never move.
Traits
Up to 32 named types, values of at most 64 characters, each type at most once per token. Readable names help collectors.
Before you register, run engine.Conformance(impl{}, 50) in your tests: it is the same self-test core runs at registration.
Check a render
Paste one SVG your engine produced. The same allowlist core runs on chain checks it here, in your browser; nothing is sent anywhere.
Publish
- 01
Set your address
Put your address in the adapter's
config.gnoand choose your fee (0–5 % of every sale). - 02
Deploy both packages
First the
p/art package, then the adapter realm, withgnokey maketx addpkg. - 03
Reserve, then register
Optionally commit your fingerprint with
core.ReserveFingerprintfirst, so nobody who sees your package can register the art before you. Then signRegisterandcore.ClaimEnginewith your author key. - 04
Choose who may use it
core.SetEnginePolicy: closed (only you), licensed (creators you grant) or open (anyone). Every engine starts closed. - 05
Open it in Studio
Studio renders samples of your engine through the chain, lists its traits and builds a form from your params schema:
/studio/?engine=<adapter path>.
An engine's registration (fingerprint, manifest, sample render) never changes. To change the art, publish a new version under a new path.