# The Economics: Write Once, Read Free Forever

ChainRender has an unusual and powerful cost model: you **pay gas once to store an app, then render it for free,
forever.** This page explains the model, the numbers, and why it works — because it's one of the strongest reasons
to build on-chain UIs at all.

## The core model

| Action | Cost | When |
|---|---|---|
| **Register app bytes** | gas, once | at deploy |
| **Render the app** | **free** | every time, forever |
| **Read live data** | **free** | every render |
| **Change the theme/look** | **free** | render-time |
| **User signs an action** | normal tx gas | only when *they* act |

The asymmetry is the point: **storage is a one-time write; rendering is an unlimited free read.**

## Why rendering is free

Rendering is a `view` function (`renderHash`) — an `eth_call`. Reads don't change state, so they cost no gas.
Whether the interpreter does a little work or a lot, whether one person renders it or a million, whether it renders
today or in ten years — **it's always free to the user.** There is no per-render cost, no metering, no rate to pay.

> A common point of confusion: an RPC provider may cap the *work* a single `eth_call` can do (a gas cap on the
> call), but that's a provider-side limit, **not a cost to the user**. And ChainRender's paginated reads handle
> apps that exceed any single-call limit. The user never pays to render.

## Why storage is a one-time write

App bytes are stored via **SSTORE2** — a pattern that stores data as contract *code* rather than in storage slots.
This is dramatically cheaper than naive `SSTORE`, and once written, the bytes are immutable and read cheaply
(via `EXTCODECOPY`) forever. You pay the write once; every future render reads those same bytes for free.

Storage runs on the order of **~216–226 gas per byte** on chains without Ethereum's Glamsterdam repricing, and
**~1,559 gas per byte** on chains with it (measured on Sepolia, October 2026: ~7.2× more; Ethereum mainnet has not
scheduled it yet). So a component's one-time deploy cost scales with its size and with the chain you deploy to —
and after that, it renders for free indefinitely. There's no recurring cost, no renewal, no re-upload.

## Concrete numbers

- **A small component:** registering one measured **~189,000 gas** for a 17-byte component (most of it fixed
  registry bookkeeping), then free renders forever. Measured before Glamsterdam; that bookkeeping is part of what the
  repricing raised.
- **A large on-chain library** (p5.js + three.js core, gzipped, ~83M gas): about **$20 at 0.1 gwei** (~$200 at
  1 gwei) to pin once, before Glamsterdam pricing — a one-time cost shared by every scene that references it. Roughly
  7× that on a chain with the repricing.
- **The framework itself:** a one-time deploy, measured at **82.5M gas** for the original 46-contract set on a local
  pre-Glamsterdam chain (the full set has since grown). That's *infrastructure*, deployed once by the operator, not
  something an app developer pays. You deploy your *app* against the live framework.

(Gas figures are indicative and depend on size, chain and gas price. Estimate with `scripts/compare-deploy-cost.mjs`,
which uses measured numbers per chain where they exist, before any mainnet deploy.)

## Why this changes the calculus

A traditional web app has *ongoing* costs — hosting, a domain, a CDN, maintenance — that never end and that
someone must keep paying or the app disappears. ChainRender inverts this:

- **No recurring cost.** Pay the one-time write; there's nothing to renew.
- **No hosting bill.** There's no server (see **[No Hosting](../concepts/no-hosting.md)**).
- **Cost scales with size, not usage.** A popular app costs the same as an unused one — because rendering is free.
  A million users cost you nothing.
- **Permanence is paid-for, once.** The app exists as long as the chain does, with no further payment.

This is what makes on-chain UIs viable as **public goods**: an app can be deployed once and serve everyone, forever,
with no one needing to keep funding its existence.

## The one-time costs, summarized

You pay gas once for each of these, then never again:
1. **Register your app's component bytes** (the app itself).
2. *(Optional)* **Register a subname** (a refundable stake, not a fee — you get it back).
3. *(Optional)* **Seed a custom theme** on-chain (once, if you commit one).
4. *(Optional, operator-level)* **Pin a rich-media library** (p5/three) if your app uses one.

Everything else — rendering, reading live data, applying themes, verifying — is free, forever.

## Related
- **[No Hosting: How It Works](../concepts/no-hosting.md)** — why there's no recurring cost.
- **[Content Addressing](../concepts/content-addressing.md)** — the immutability that makes read-once-store-forever work.
- **[Deploying an App](../guides/deploying.md)** — the one-time write in practice.
