Guide: Page Effects (CR-FX)
A page effect is drawn over an app's own HTML in the viewer: a lens, jelly, 3D columns, glass. The app underneath stays the app. Its text can be selected, its inputs typed into and its buttons pressed, and anyone can restore the plain page with one tap. Effects use HTML-in-Canvas where the browser has it, and a CSS version everywhere else.
These are not the post-processing effect presets (SVG filters that are part of the on-chain floor). A page effect is ⚙ above the floor: it is never graded, and the review lists it under "Not checked".
Design and rules: docs/206-cr-fx-html-in-canvas-effects.md in the repository. Examples: examples/cr-fx/.
Use an effect in the builder
- Choose a chain whose RenderRouter has the VERSION_5 interpreter, and set the project's Mode to Enhanced.
- ⋯ More → ⚙ Page effects. The list shows the effects published on that chain (from
chains.json); you can also load one by manifest hash, or from files while you are writing one. - Each effect is loaded from DependencyRegistry and re-hashed before it runs. The preview draws it over your
project's real render (RenderRouter
renderBlob, aneth_call: no gas, nothing deployed), in the same sandboxed frame the viewer uses. Try each tier with Preview tier. - Tune the parameters (the controls come from the effect's manifest). For an effect with targets (Data city's
cell), select a node on the canvas and press Mark the selected node. - Apply to app writes two hints into the root box:
fx(the manifest hash) andfxp(the parameters). Deploy as usual; the viewer draws the effect. Remove effect takes them out.
Without the panel, the same hints can be typed into the root box's Presentation → hints field:
{"fx":"0x9d8b30001adf1c263fa74207688625ae75065cacbac28655bb482839b442596c","fxp":"wobble:18"}
What the viewer guarantees
- The manifest and code are read from DependencyRegistry and re-hashed; a mismatch, or an effect that is not registered, shows the plain app with a note.
- The effect runs in a
sandbox="allow-scripts"frame with no origin, no network and no storage. - An effect can change how the page looks, never what it does. A click inside the effect reaches the viewer as the index of an action; the viewer types the values into its own copy of the app and presses its own button, so the confirm panel and the wallet see only what the app's bytes say. An action the app does not have is refused.
- Restore page shows the viewer's own copy of the app and is remembered per app on that device.
Write an effect
node scripts/fx/new-effect.mjs glow --kind material --webgl --dir effects # a template that already passes the checks
node scripts/fx/test-effect.mjs effects/glow.js # every tier in Chromium, with screenshots
Then open the builder's panel, choose From files, and pick glow.js and glow.manifest.json to see it over your
own app.
The contract (version 1)
The effect calls CRFX.effect({...}) with these functions. The runtime calls them; the effect never owns the page.
| Function | When |
|---|---|
init(ctx) |
once the tier is chosen; throw to fall back to the next tier |
frame(t, dt) |
every frame; t is the only time an effect may use |
resize(w, h, dpr) |
on layout change |
floorUpdate() |
the page changed (live values) |
toFloor(x, y) |
canvas px → page px, for browsers that do not hit-test drawn elements |
plain(), dispose() |
Restore page, or the tier ends |
ctx gives the page (root), the canvas and its context (gfx), the tier, the params, the targets the app
marked, rectOf(el), pointer, motion, seed, read-only chain access (chain), and the drawing helpers:
drawFloor2D(g, x, y[, w, h, { preserveElementGeometry }]), uploadFloor(gl) / uploadError() for WebGL, and
sync(el, matrix) so clicks and focus follow a 3D drawing.
Tiers
webgl → canvas2d → css → plain. List the ones you implement, best first. Always include css (Safari,
Firefox and phones get it; the checks warn without it). The runtime detects HTML-in-Canvas by feature and supports the
early API (Chromium with --enable-blink-features=CanvasDrawElement), Chrome 150–154 and the current shape.
Rules the checks enforce
- No
fetch,XMLHttpRequest,WebSocket,eval,new Function,import(),localStorage,document.cookie, orparent.postMessage: the frame forbids them, or only the runtime may do them. - No
Date.now,performance.noworrequestAnimationFrame: uset. The test harness runs the same ticks twice and compares the pixels. - Never read pixels back from the canvas: drawing the page taints it.
- Never add buttons or actions. Anything interactive belongs in the app.
motion: "strong"effects get the CSS tier or the plain page when the viewer asks for reduced motion.
The manifest
<name>.manifest.json next to the code: name, version, kind (any short lowercase name; lens, deform,
material, particles, surface, data are listed by kind), tiers, motion, targets ("floor" or a list of
target names), params (number with min/max/step/default, color, bool, enum with values),
doesNotEstablish, credits. Parameter names are hint keys: lowercase letters and digits.
Publish an effect
node scripts/fx/package-effect.mjs effects/glow.js # checks, then writes build/fx/glow.code.js + glow.manifest.json
export L2_TESTNET_RPC_URL="<RPC>"; read -rs L2_TESTNET_PRIVATE_KEY && export L2_TESTNET_PRIVATE_KEY
# the two commands it prints: code first, then manifest (each skipped if already registered)
unset L2_TESTNET_PRIVATE_KEY
node scripts/build-chains-manifest.mjs # lists it in chains.json → the builder's panel
Both files are stored raw, so each registry key is the keccak256 of the bytes and every reader re-hashes them. Anyone
can publish an effect; the list in chains.json only points at it, and a name is not trust: the panel shows the
hash, and the code is what was checked.
Honest limits
- HTML-in-Canvas is on in the Claude desktop apps and in Chromium with the flag; elsewhere the CSS tier runs.
- In the viewer, the provenance lens does not yet get each value's source.
- No WebGPU tier and no stacking of effects yet (docs/206 §16).