Modules

Deploy a module

Publish a fully on-chain static site and point your .quai name at it — entirely from the CLI. The bytes are stored in contract state and verified by hash on load.

Before you start

  • Clone the repo and install dependencies with npm install.
  • You own the .quai name you want to bind (register it first on the site).
  • A funded Quai key for gas, set in .env.
.env
CYPRUS1_PK=0xyour_private_key
MAINNET_RPC_URL=https://rpc.quai.network/cyprus1

Configuration

Every step below is driven by environment variables. The ones you’ll touch most often:

CYPRUS1_PKPrivate key that signs and pays for the deploy. (MAINNET_CYPRUS1_PK takes priority if set.)
MAINNET_RPC_URLQuai RPC endpoint. Defaults to https://rpc.quai.network/cyprus1.
QNS_SITE_DIRFolder of files to publish. Defaults to examples/static-site.
QNS_ENTRY_PATHEntry file route, e.g. /index.html. Auto-detected if omitted.
QNS_SITE_TITLEHuman title stored in the manifest.
QNS_NAMEThe .quai name this site will be bound to.
QNNS_CONTRACTCanonical QNNS address — required when setting the anchor.
SET_ANCHORSet to true to actually write the anchor on-chain.

Publish in three steps

01

Publish the site bytes

Chunk, hash, and upload your files. This deploys a QNSStaticContentStore and a QNSStaticSiteModule, then writes a deployment record to deployments/ and prints the 96-byte anchor. It does not bind your name yet.

publish
QNS_NAME=yoursite \
QNS_SITE_DIR=./examples/static-site \
QNS_SITE_TITLE="My on-chain site" \
npm run publish:static:mainnet
02

Bind your name to the module

Write the anchor into the registry so yoursite.quai resolves to the module you just deployed. This requires that your wallet owns the name. Set SET_ANCHOR=true to send the transaction (omit it for a dry run).

anchor
QNS_NAME=yoursite \
QNNS_CONTRACT=0x001d4668f5621ee6211C396243faFe163A057516 \
SET_ANCHOR=true \
npm run anchor:module:mainnet
03

Verify and view

Re-read the module from chain, recompute the manifest and file hashes, and confirm they match. Then load it the way a wallet would, or open it in the inspector.

verify + load
npm run verify:module:mainnet

QNS_NAME=yoursite npm run load:module:mainnet
Once the anchor is set, the name resolves natively in a QNS-aware wallet (Pelagus) at yoursite.quai, and in the module inspector.

Shortcut: deploy an example

To see the whole flow end-to-end without building files, deploy one of the bundled examples:

examples
# fully on-chain fixed static site
npm run deploy:examples:mainnet

# HTML + CSS static site
npm run deploy:examples:html:mainnet

Next

How modules work

The anchor, manifest, and loader behind these commands.