Skip to main content

Solana

UR registry types for Solana offline signing.

Type Map

  • Request UR: sol-sign-request (transaction/message bytes + BIP-44 path)
  • Response UR: sol-signature

Steps

  1. Prepare Solana transaction or message bytes and derive path
  2. Build sol-sign-request and show as animated QR
  3. Scan device response → decode sol-signature → attach to transaction
  4. Submit the transaction to the Solana network

Samples

Build Solana sign request (UR)

import { SolSignRequest, SignType } from "@keystonehq/bc-ur-registry-sol";
import { CryptoKeypath, PathComponent } from "@keystonehq/bc-ur-registry";
import { airGapUrUtils } from "@keystonehq/keystone-sdk";

// path note: BIP44: m/44'/501'/0'
const keypath = new CryptoKeypath([
new PathComponent({ index: 44, hardened: true }),
new PathComponent({ index: 501, hardened: true }),
new PathComponent({ index: 0, hardened: true }),
]);

const req = new SolSignRequest({
signData: Buffer.from(rawTxBytes), // transaction value or message bytes
derivationPath: keypath,
signType: SignType.Transaction, // 也可以改成 SignType.Message
});

const ur = req.toUR();
const frames = airGapUrUtils.urToQrcode(ur);

Decode Solana signature (UR)

import { URDecoder } from "@ngraveio/bc-ur";
import { SolSignature } from "@keystonehq/bc-ur-registry-sol";

const dec = new URDecoder();
// pass every scanned frameString into dec.receivePart
if (dec.isComplete()) {
const ur = dec.resultUR(); // expected UR type: 'sol-signature'
const signatureData = SolSignature.fromCBOR(ur.cbor);
const signature = signatureData.getSignature();
// Attach the signature to the transaction and submit it
}