WizardConnect lets a dapp exchange encrypted messages with an HD wallet through a Nostr relay. The dapp shows a wiz:// pairing link as a QR code for the wallet to scan. The hdwalletv1 session supplies xpubs scoped to named paths so the app can derive public keys locally.
Pair a wallet
Use @wizardconnect/core for the relay and @wizardconnect/dapp for the session manager. Register the wallet-ready handler before presenting the pairing URI. Keep the URI and stored relay credentials inside the pairing and reconnect flows.
import { initiateDappRelay } from '@wizardconnect/core';
import { DappConnectionManager } from '@wizardconnect/dapp';
const manager = new DappConnectionManager('BCH demo');
manager.on('walletready', (wallet) => showWallet(wallet.wallet_name));
const relay = initiateDappRelay(({ client, status }) => {
manager.updateConnection(client, status);
});
manager.attachRelay(relay);
showPairingQr(relay.uri);
showWallet and showPairingQr are app callbacks. The manager also exposes stored session handling, and the React package provides an integration hook.
Build and sign
- Read the approved path names and derive only the child public keys the app needs. Common path names are
receive,changeanddefi. - Build the transaction with the full data for each UTXO it spends, including BCH value, locking bytecode, and any tokens. For each wallet-controlled input, identify its input index, path name and child address index.
- Send the transaction and the input paths with
manager.signTransaction. For app-side broadcast, setbroadcast: falseand verify the returnedsignedTransactionbefore submitting it.
const result = await manager.signTransaction({
transaction: { transaction: rawUnsignedHex, sourceOutputs, broadcast: false },
inputPaths: [[0, 'receive', 3]],
});
if (result.error) throw new Error(result.error);
This example assumes input 0 spends the fourth child of the approved receive path. The address index comes from the wallet path used for the UTXO. Scope xpub access appropriately because an xpub reveals addresses derived beneath that path.
Reconnect, cancel and disconnect
Reconnect using the existing relay identity and session state. The SDK can re-deliver pending requests when the wallet returns, so keep one logical signing request per user action. Pass an AbortSignal to cancel stale requests. On disconnect, clear cached session paths and any app state derived from the session.
WizardConnect protocol reference · Riften Labs dapp SDK guide
An application that uses a decentralized system such as BCH and can ask a wallet to authorize an action or payment.A wallet that derives a tree of keys from one seed, with separate branches for receiving and change addresses.Software or a device that manages addresses and tracks UTXOs, with signing wallets also holding private keys to authorize payments.An encoded extended public key that lets a watch-only wallet derive non-hardened public keys and link their addresses.A cryptographic value derived from a private key and used to verify its signatures.A Bitcoin Cash record that defines new outputs and, for a payment, identifies the UTXOs being spent.The basic unit of spendable value on Bitcoin Cash, holding satoshis and any attached tokens under the spending rules defined by its locking bytecode.The currency unit of Bitcoin Cash, equal to 100,000,000 satoshis.The program in an output that specifies the conditions required to spend it.A transaction record that identifies a UTXO to spend and supplies its unlocking bytecode and sequence number.A shareable identifier a wallet decodes into a payment’s locking script, usually in CashAddr format on BCH.