Write a renderer
A renderer builds tokenURI and contractURI. Both Surface generations call
the same two renderer functions, passing the collection address explicitly:
interface IRenderer {
function tokenURI(address collection, uint256 tokenId) external view returns (string memory);
function contractURI(address collection) external view returns (string memory);
}One renderer can serve multiple collections. It may read the seed, owner, companion contracts, other tokens, or live chain state. Its output depends on those inputs as well as its own code.
Reading collection state through ISurfaceView
The legacy ISurfaceView read shape is v1 only. Current v2 has no idMode()
and does not return a SurfaceConfig struct. Sharing IRenderer does not make
the collection read ABIs interchangeable. A renderer must use the right read
interface for its target collection.
For current v2, the relevant reads are:
interface ISurfaceV2Reads {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function owner() external view returns (address);
function totalSupply() external view returns (uint256);
function tokenSeed(uint256 tokenId) external view returns (bytes32);
function config() external view returns (
address renderer,
address minter,
uint256 supplyCap,
uint16 royaltyBps,
address royaltyReceiver,
uint256 minted
);
}V2 stores every seed at mint and keeps it readable after burning. The token
checks live ownership before forwarding its own tokenURI call, so the token's
metadata entrypoint reverts for a burned id even though tokenSeed remains
readable. See the token reference.
For v1, use ISurfaceView: config()
returns (SurfaceConfig, minted) and idMode() distinguishes sequential and
pooled collections. The v1 seed formula also differs from v2; always read
tokenSeed instead of reproducing it in the renderer.
DefaultRenderer
DefaultRenderer was a v1 stock renderer backed by RenderAssets. These
modules were not part of the recorded v1 mainnet deployment, and their Solidity
sources and contract-reference pages are removed from the current tree.
Legacy ABI exports may remain for historical integrations; they do not identify
a current stock renderer to deploy or use. Current v2 requires the artist's
own nonzero deployed renderer address.
ScriptyRenderer (bring-your-own generative)
ScriptyRenderer was a v1 generative template using ScriptyBuilderV2 and the
legacy collection read shape. Its template sources and reference page have
been retired too. An existing work using that code must retain its own source
and dependencies; the old template is not a current v2-compatible renderer.
A new generative renderer can implement IRenderer directly and assemble its
own HTML metadata. If it adopts the
injection convention, inject
the resolved seed as tokenData.hash and pin the work's dependency bytes.
Previews can optionally implement
IPreviewRenderer; the core does
not require this extension.
Fully onchain Solidity SVG
A Solidity renderer can derive an SVG from tokenSeed, wrap it in metadata
JSON, and return a data URI. Build the JSON with correct escaping and use the
collection version's actual getters. The former shared MetadataJson helper
was removed with the old modules; it is not a current library dependency.
Installing a renderer
Current v2 uses owner-only setters:
function setRenderer(address renderer) external;
function renderer() external view returns (address);The address must be nonzero and contain deployed code. V2 has no default
renderer fallback, admin set, or lockRenderer. The owner can replace the
pointer until ownership is renounced. Renunciation also freezes the token's
other owner-only settings and the bound FixedPriceSale configuration; it is
not a renderer-only lock. See Surface v2.
V1 instead permits owner/admin renderer changes and has a separate one-way
lockRenderer(). Its recorded mainnet factory has no default renderer, so
artists using that factory also supply their own renderer at creation.
Renderer permanence
Fixing the pointer fixes which renderer answers metadata calls. It does not freeze mutable state in that renderer, external dependencies, block state, or any other input the art reads. Immutable code can still produce changing work. For a fixed presentation, identify and freeze the work's relevant inputs as well as its rendering code.
See IRenderer, Surface v2, and the Injection convention.