Skip to content
Glyph

Glyph Connect

TypeScript SDK for typed glyph:// wallet requests and approvals.

On this page
  1. The request builders
  2. Build and launch a transfer
  3. Pick the result path first

Most wallet integrations start with a custom message format and end with a parser that trusts whatever came back. Glyph Connect makes the request and the result one typed contract.

The SDK builds a request for a transfer, contract call, signature, verification, or connection. It wraps the request in a versioned envelope with a canonical hash, then gives you a way to launch it and check the response against the request you sent.

The request builders

  • Five request builders: transfer, contract input, sign, verify, and connect
  • Envelope protocol v2 with a canonical request hash
  • Results through a callback, redirect, or the Glyph relay
  • Zero runtime dependencies and browser helpers

Each builder creates a request for one operation. A transfer carries a recipient and an amount. A contract input carries the contract index, input type, and payload. Sign and verify work with a message. A connect request asks for an identity and the permissions the app needs.

The envelope adds the protocol version, network binding, and request hash. The hash is calculated over the canonical request, so the wallet and the app can refer to the same payload when they exchange a result.

Build and launch a transfer

Install the package:

bun add @glyph-oss/connect

The dApp origin must be a canonical HTTPS origin. The callback must also use HTTPS and match that origin.

import {
  createEnvelope,
  createTransferRequest,
  launchGlyphRequest,
} from "@glyph-oss/connect";

const request = createTransferRequest({
  type: "transfer",
  dapp: { name: "Example", origin: "https://example.app" },
  to: recipientIdentity,
  amount: "1000",
});

const envelope = createEnvelope(request, {
  callback: "https://example.app/api/glyph/callback",
});

launchGlyphRequest(envelope);

launchGlyphRequest opens the glyph:// request from a user action. The wallet shows the request, the user approves or rejects it, and the result goes to the callback you selected.

A server callback can parse the body with the nonce and type from the original request:

import { parseCallbackResponse } from "@glyph-oss/connect";

const result = parseCallbackResponse(await callbackRequest.json(), {
  nonce: request.nonce,
  type: request.type,
});

parseCallbackResponse checks the shape and binding. For a signed callback envelope, use verifyCallbackEnvelope and verify the Qubic signature before you trust the decoded result.

Pick the result path first

A callback fits a dApp that controls the page or server that receives the result. A redirect fits a flow that leaves the app and returns through a URL. The Glyph relay fits a dApp that cannot receive a direct callback or needs the result on a server.

The request can stay the same across those paths. Decide where the result should land before you build the launch step.

  1. 1Install @glyph-oss/connect in the app.
  2. 2Choose the builder for the operation and fill in the typed fields.
  3. 3Launch the envelope from a user action.
  4. 4Parse or verify the result, then check the nonce and request hash before changing app state.
Request builder referenceThe fields and result shape for each builder. Glyph Connect sourceThe TypeScript package on GitHub.

For a result that has to cross a server without a public callback route, continue with Glyph Relay. For a contract call, pair the request with Glyph Contracts.

Next steps

Use Glyph Connect on its own or with the rest of the toolchain.