A minimal Next.js reference for Qubic wallet connections and reviewed contract actions.
Glyph Starter is a small, inspectable Qubic dApp baseline. It composes the
shared @qubic.org/react wallet provider with supported connector paths and
three focused actions:
- Sign & Verify signs a message or checks a signature for the active identity.
- Lock QUs prepares QEarn's generated
Lockprocedure. - Send QUs prepares one direct whole-QU wallet transfer.
The action surface is deliberately curated. There is no generic contract form,
raw contract index, input type, or binary payload field. QEarn uses its reviewed
@qubic.org/contracts builder, while Send QUs uses the wallet's direct transfer
capability. Every request still requires wallet approval.
| Connector | Behavior |
|---|---|
| Qubic browser extension | Uses the injected provider through a compatibility adapter that adds the current from identity to every transaction. It is disabled when not installed. |
| WalletConnect | Uses QR pairing, requires NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, validates the granted mainnet account and required methods, and adds its active from identity to every request. |
| Glyph Wallet | Uses a Relay v2 desktop deep link and requires a public HTTPS deployment. |
A disconnected action presents only Connect wallet. Inputs and its submit control appear only once an account connects.
- Lock QUs attaches the entered positive whole-QU amount to QEarn contract 9, input type 1.
- Send QUs validates one Qubic recipient identity and a positive whole-QU amount before a direct wallet transfer request.
Review every wallet request. A procedure may change on-chain state. This starter does not initiate requests automatically.
Requirements: Node.js 20+ or Bun 1.3+, plus a supported wallet only when you want to exercise a connector.
bun install
bun run devOpen http://localhost:3000. npm users can run npm ci
and npm run dev. Tests use bun:test, so they still require Bun.
Optional public deployment settings belong in .env.local:
# Blank uses the current browser origin. An override must match the public HTTPS origin.
NEXT_PUBLIC_APP_ORIGIN=
# Enables WalletConnect in the chooser.
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_idThese values are browser-visible. Never put private keys, API tokens, relay
capabilities, callback URLs, or wallet session secrets in NEXT_PUBLIC_*.
Source paths use kebab-case. Component symbols stay PascalCase.
components/starter-app.tsxowns shell composition, hero CTAs, and modal state.components/wallet/wallet-session-provider.tsxowns one active connector, connection state, shared request locking, safe feedback, and background Glyph relay preparation.components/wallet/request-status.tsxturns shared wallet progress and outcomes into global, identity-aware toasts rather than dialog cards.components/signatures/signatures-screen.tsxowns signing and verification inputs and durable signature results.components/qearn/lock-qus-screen.tsxowns the direct QEarn Lock form.components/transfers/send-qu-screen.tsxowns the direct QU transfer form.lib/contracts/starter-procedures.tsis the reviewed typed boundary for QEarn Lock, direct-transfer validation, identity validation, and payload conversion.lib/connectors/qubic-extension.tsadapts the injected provider by attaching its current account identity to each extension transaction request.lib/connectors/glyph.tsisolates the Glyph Relay v2 adapter and native smart-contract request path.
The browser extension uses a local compatibility adapter that reads and attaches
its active from identity to each transaction. WalletConnect uses the shared
sendTransaction call. Glyph uses requestGlyphScCall() for QEarn and
requestGlyphTransfer() for direct transfers through its signed Relay boundary.
lib/connectors/wallet-connect.ts is a small compatibility adapter around the
WalletConnect client. It accepts only sessions granting the app's requested
mainnet methods and a checksum-valid account. It then adds that connected sender
to map-shaped qubic_sign and transaction inputs that Qubic Wallet expects.
When the wallet chooser opens on a valid HTTPS origin, the app may prepare a Relay session in the background. Preparation registers a session only. It never launches or approves a wallet action. A prepared session lets the next deliberate Glyph action use one click. If preparation is incomplete, the user sees a retry prompt instead. Local HTTP pages do not register a relay session.
The adapter verifies signed callbacks against the expected request type, nonce,
request hash, app identity, callback session, account identity, and
qubic:mainnet. Relay capabilities and signed payloads stay inside the adapter
and are not copied to UI diagnostics.
Use the existing seams rather than putting connector-specific logic in a page:
| Need | Change |
|---|---|
| Add or remove a connector | lib/connectors/index.ts and its availability handling |
| Change wallet state behavior | components/wallet/wallet-session-provider.tsx |
| Add a reviewed contract action | lib/contracts/starter-procedures.ts, a feature-local screen, and tests |
| Replace the signing flow | components/signatures/signatures-screen.tsx |
| Change the shell | components/starter-app.tsx and app/globals.css |
For every new procedure, keep a typed builder, validate user fields before a wallet request, document whether QU is attached, and add a fixture test for the exact request shape. Do not add a raw ABI form to this starter.
| Command | Purpose |
|---|---|
bun run dev |
Start the development server. |
bun run typecheck |
Check TypeScript. |
bun run lint |
Run ESLint. |
bun run test |
Run type checking, linting, and isolated tests. |
bun run build |
Build the static production output. |
bun run qa |
Run responsive Playwright and axe checks against an already-served app. |
For browser QA:
bun run build
bunx serve out -l 4174
# In another terminal:
bun run qa
node scripts/qa-wallet-boundary.mjsqa.mjs checks desktop and mobile layouts, theme persistence, accessibility,
connector chooser behavior, direct disconnected action gates, and absence of
runtime errors. qa-wallet-boundary.mjs runs the built UI against a synthetic
extension to check rejection, retry, signing, direct QEarn and transfer request
shapes, identity-aware toasts, and account behavior.
Those checks do not prove an actual native wallet round trip. A deployed HTTPS build and an authorized test wallet are still required to verify a real Glyph or WalletConnect approval, or an on-chain transaction.
app/ Route, metadata, global styling
components/
starter-app.tsx Hero, account header, and modal composition
wallet/ Connection, account UI, and global toasts
signatures/ Sign and verify flow
qearn/ Direct Lock QUs flow
transfers/ Direct Send QUs flow
lib/
contracts/ Typed, reviewed starter procedures
connectors/ Connector registry and Glyph Relay adapter
scripts/ Browser, wallet-boundary, and tactile UI QA
This is independent software built for Qubic. It is not an official Qubic organization product.