Skip to content

About

Reference Qubic dApp with Glyph Wallet, browser extension, and WalletConnect integrations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Glyph Starter

A minimal Next.js reference for Qubic wallet connections and reviewed contract actions.

Qubic · Glyph Connect

What this is

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 Lock procedure.
  • 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.

Wallet behavior

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.

Quick start

Requirements: Node.js 20+ or Bun 1.3+, plus a supported wallet only when you want to exercise a connector.

bun install
bun run dev

Open 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_id

These values are browser-visible. Never put private keys, API tokens, relay capabilities, callback URLs, or wallet session secrets in NEXT_PUBLIC_*.

Architecture

Source paths use kebab-case. Component symbols stay PascalCase.

  • components/starter-app.tsx owns shell composition, hero CTAs, and modal state.
  • components/wallet/wallet-session-provider.tsx owns one active connector, connection state, shared request locking, safe feedback, and background Glyph relay preparation.
  • components/wallet/request-status.tsx turns shared wallet progress and outcomes into global, identity-aware toasts rather than dialog cards.
  • components/signatures/signatures-screen.tsx owns signing and verification inputs and durable signature results.
  • components/qearn/lock-qus-screen.tsx owns the direct QEarn Lock form.
  • components/transfers/send-qu-screen.tsx owns the direct QU transfer form.
  • lib/contracts/starter-procedures.ts is the reviewed typed boundary for QEarn Lock, direct-transfer validation, identity validation, and payload conversion.
  • lib/connectors/qubic-extension.ts adapts the injected provider by attaching its current account identity to each extension transaction request.
  • lib/connectors/glyph.ts isolates 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.

Glyph relay behavior

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.

Adaptation guide

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.

Commands

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.mjs

qa.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.

Project map

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.

About

Reference Qubic dApp with Glyph Wallet, browser extension, and WalletConnect integrations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages