9. Publishing
A publisher turns a folder into lns-links/1 lists, uploads the files and lists to Logos Storage, and points the LNS name's record at the root list. lns publish does this in one command, and can deploy the same folder to an https:// host in the same run.
Describes lns publish from the same source as the gateway, round 3 (single-publish.mjs, publish.mjs, icon.mjs), with the names CLI for LEZ 0.4. Other publishers may work differently; only the boxed requirements apply to all of them.
9.1 Overview
lns publish runs from the root of a site's repository, where a file called lns.json says what to publish and where. It needs Node 24 or newer, a Logos Storage node to upload to, and the names CLI with the wallet that owns the name. It has no npm dependencies.
node /path/to/lns-gateway/lns.mjs publish [--dry-run] [--lns-only] [--https-only] [--yes] [--strict] [--no-avatar]
It never signs anything itself. The record update is done by your own names CLI, which uses your own wallet. lns publish never reads, prints or passes private keys or passwords. Because Logos Storage has no storage rent or marketplace yet, files stay reachable only while a Storage node keeps them (section 5.11). If the name is held privately, signing the record update also requires a local proof that takes minutes (section 4.9).
A publisher MUST compute the SHA-256 of every file and list from the bytes on its own machine, write it on every list entry, and set cid.sha256 to the root list's SHA-256 in the same record update that sets cid.
publish.mjs hashes each file and each list locally (sha256Hex(bytes), sha256Hex(listBytes)); buildNamesProfileArgs in single-publish.mjs puts --cid, --set cid.sha256=… and --set cid.type=links in one names profile call.
A publisher SHOULD finish uploading every file and list before it updates the record, so the record never points at content that is not there yet.
lns publish uploads in step 2 and signs in step 5, and stops before signing if the upload fails.
9.2 lns.json
| Field | Required | Meaning |
|---|---|---|
name | yes | The LNS name to publish to, bare (alice). |
folder | yes | The site folder, relative to lns.json. |
title | no | Written as # title on the root list (section 5.4). |
exclude | no | Glob patterns (*, **, ?) left out of the LNS tree but kept for https://, for example ["_headers"]. A pattern ending in / matches folders only. |
icon | no | A PNG, JPEG, GIF or WebP inside folder, used as the https:// favicon and the LNS avatar (9.5). |
storage | for LNS | The Logos Storage REST API URL. /api/storage/v1 is added if missing. Falls back to LOGOS_STORAGE_API. |
rpc | no | LEZ sequencer JSON-RPC URL. Default https://lez.nameswallet.app/, or LNS_SEQUENCER_URL. |
registry | no | LNS registry program ID. Default 6Yxj5k8AiuBSuMAYVQFGrYKjJGUSSaWWgoB9D9XXN3gA, or LNS_REGISTRY. |
names | no | The names CLI command or path. Default names. |
https.url | unless --lns-only | The public https:// base URL of the same site. |
https.command | unless --lns-only | Your deploy command. It runs in the repository root through a shell, with LNS_ROOT_CID and LNS_ROOT_SHA256 set. Its exit code decides success. |
lns.replace | no | Map of site paths to { "command", "output" }: a static file that replaces that path in the LNS tree only (9.8). command is optional when output already exists. |
lns.excludeScripts | no | true leaves .js and .mjs files and <script> tags out of the LNS tree only. Default false. |
maxFiles, maxBytes, maxFileBytes | no | Size limits checked before upload. Defaults 2,000 files, 200 MiB in all, 100 MiB per file. |
Dotfiles and dot-folders, including .well-known/, never enter the LNS tree. Empty folders are skipped. Symbolic links are refused, so a tree is never published with parts silently missing.
9.3 The six steps
- Check. The folder exists, every name in it is a valid
lns-links/1name (section 5.5), there are no symbolic links, and the sizes are within limits. The icon is checked. Anything the content profile (section 7) would remove or block is reported as a warning, and so is every page with a<script>tag and nolns.replaceentry ("shows without its scripts on LNS"). Warnings do not stop the run unless--strictis set. Nothing has been sent yet. - LNS upload. If
iconis set, a<link rel="icon">is added to pages that have none.lns.replacecommands run. Then the lists are built bottom-up in canonical form (section 5.6), compared with the tree the name points to now, and only new or changed files and the lists above them are uploaded. - Proof.
<folder>/.well-known/lns.jsonis written for thehttps://copy: a JSON object with the fieldsversion(1),name,rootCid,rootSha256andpublishedAt. It is left alone if it already matches. - https.
https.commandruns. It is skipped when nothing changed and<https.url>/.well-known/lns.jsonalready shows the same root. - Sign. The exact record update and its expected fee are shown, you confirm (unless
--yes), and yournamesCLI runs it:
This setsnames profile <name> --cid <rootCid> --set cid.sha256=<rootSha256> --set cid.type=links [--avatar <icon>]cid,cid.sha256,cid.typeand, with an icon,avatarin one transaction. It is skipped when the record already has that root and avatar. Without a terminal and without--yes,lns publishrefuses to sign. After a successful update, if the gateway operator's purge settings are present, it purges the gateway's CDN for the changed URLs (section 8.6). Without them, nothing is purged and the gateway catches up within a few minutes. - Verify. It fetches
<https.url>/.well-known/lns.jsonand one page, resolves the name on chain, and reports eitherhttps and lns:// both serve root <cid>or which side is behind.
The order is chosen so the chain never gets ahead of the https:// copy by accident: if the deploy fails, lns publish stops before signing.
9.4 Flags
| Flag | Effect |
|---|---|
--dry-run | Prints every step and command. Uploads nothing, adds no favicons, runs no replacement commands, writes no proof, deploys nothing and signs nothing. |
--lns-only | Check, LNS upload, sign and the LNS half of verify. No favicons, proof or https.command. |
--https-only | Check, favicons, proof, https.command and the https half of verify. No upload and no signing. |
--yes, -y | Signs without asking. |
--strict | Any content-profile warning stops the run at step 1. |
--no-avatar | Leaves --avatar out. An avatar already on chain is kept. |
--icon, --config, --storage, --rpc, --registry, --names, --json | Override the matching setting, or print JSON. |
9.5 Icon and avatar
One icon serves both copies. On https:// it becomes the favicon of every page that has no icon link of its own. On LNS it becomes the record's avatar (section 4.6), which the Names Browser shows on tiles, history and tabs.
- Format: PNG, JPEG, GIF or WebP, read from the file's own header.
.icoand.svgare refused, because SVG can carry script. - Size:
lns publish(icon.mjs) caps the raw image file at 12 KiB (12,288 bytes), the size of a whole sealed record. Because the Names Browser caps the base64data:URL string at 12,288 bytes, keep raw icons under about 9 KiB so they fit after base64 encoding. The registry library also caps each text value at 512 bytes; see the open question in section 4.6. - Dimensions: at most 256 by 256 pixels.
If a configured icon fails, lns publish stops before anything is sent, with a plain reason such as assets/icon.png is 31 KB; the avatar limit is 12 KB: use a 64x64 PNG. With no icon set, it tries the <link rel="icon"> of the root index.html, then favicon.png at the site root. If that file is unusable, it warns and goes on without an avatar.
9.6 Costs
| Action | Cost on the LEZ 0.4 testnet |
|---|---|
Record update (names profile, step 5) | about 250,000 LEZ, whatever the size of the site |
| Uploading files and lists to Logos Storage | no LEZ: lns publish pays only for the record update |
| A re-run where the root and avatar are unchanged | nothing: no transaction is sent |
| An on-chain page instead (section 4.5) | roughly 185 to 220 LEZ per byte, paid again on every change |
The 250,000 figure is the estimate lns publish shows before you confirm. The names CLI and the chain decide the real fee.
9.7 Re-runs and failures
Running lns publish again is always safe. Unchanged files and folders are reused by hash and not uploaded again (it reads up to 50,000 files and 50,000 folders of the old tree to compare). An unchanged proof file is left as it is, an up-to-date https:// host is not redeployed, and an unchanged record gets no transaction.
When a step fails, the message says which copy is ahead and how to finish:
| Failure | State | To finish |
|---|---|---|
Check, icon, --strict or a replacement command | Nothing was changed. | Fix it and run again. |
| Upload | Neither https:// nor the record was changed. | Check the Storage node and run again. |
https.command | LNS Storage is ahead; the record was not changed. | Fix the deploy and run again. |
Signing declined or the names CLI failed | https:// is ahead; the record still points at the old root. | Run the printed names profile … command, or run again. |
| Verify | One side is still serving the old root, for example during CDN or chain lag. | Wait, or run again with --https-only or --lns-only. |
9.8 Script pages
LNS clients run no page code (section 7), so a page that builds itself with JavaScript shows empty on LNS. There are two tools for this:
lns.replacemaps a site path to a command and an output file. The command runs in the repository root before upload, withLNS_NAMEandLNS_RPCset, and its output takes that path's place in the LNS tree only. A non-zero exit or a missing output stops the run before anything is uploaded.lns.excludeScripts: trueleaves.jsand.mjsfiles and<script>tags out of the LNS tree, which keeps it smaller. Thehttps://copy keeps its scripts.
Step 1 lists every page that still has a <script> tag and no replacement, so you can see what will show without its scripts.
9.9 Examples
9.9.1 LNS only
The site in Appendix C: three files for alice, with this lns.json:
{
"name": "alice",
"folder": "site",
"title": "Alice",
"storage": "http://127.0.0.1:8183"
}
Preview, then publish:
node /path/to/lns-gateway/lns.mjs publish --lns-only --dry-run
node /path/to/lns-gateway/lns.mjs publish --lns-only
The first run uploads five blobs (three files, two lists) and asks to run:
names profile alice --cid CIDrootlist \
--set cid.sha256=46e9b7064d5ff69a69d2cd6a40235c933f35955d254d5fefd47f00c5b12a07f8 \
--set cid.type=links
Here CIDrootlist stands for the real root CID that Storage returned. After it lands, lns://alice/ works in the Names Browser and https://alice.lnsweb.online/ on the gateway. Change only docs/intro.html and run again: it uploads the new file, the docs list and the root list, reuses index.html and style.css, and sends one more record update.
9.9.2 https:// and LNS together
{
"name": "nameswallet",
"folder": "site",
"icon": "assets/icon.png",
"exclude": ["_headers"],
"lns": {
"replace": {
"apps/index.html": {
"command": "node apps-src/static.mjs",
"output": "build/lns/apps/index.html"
}
},
"excludeScripts": true
},
"storage": "http://127.0.0.1:18183",
"https": {
"url": "https://nameswallet.app",
"command": "npx cf deploy"
}
}
One run builds a static apps/index.html for LNS, uploads what changed, writes the proof, deploys with npx cf deploy, updates the record with the new root and the icon as avatar, and checks that both copies serve the same root. If nothing changed, it uploads nothing, deploys nothing and sends no transaction.
This document is published the LNS-only way. Its lns.json is in Appendix C.5.
9.10 Safety
- Keys.
lns publishnever reads, prints or passes keys or passwords. Signing happens in yournamesCLI, which is started directly, not through a shell. - Hashes. Every SHA-256 is computed on your machine. The Storage node cannot change your site, because the record pins the root's hash and each list pins what is below it. It can lose or withhold files.
- Your own
lns.json.https.commandand everylns.replacecommand run through a shell with your user's rights. Only runlns publishon alns.jsonyou wrote or trust, as you would aMakefile. - Check first.
--dry-runshows every command, including the record update, before anything happens.
A publisher SHOULD show the exact record update and ask for confirmation before it signs.
single-publish.mjs step 5 prints the names profile command and fee, asks unless --yes, and refuses without a terminal.