selectStxDerivation
Usage
import { selectStxDerivation } from '@stacks/wallet-sdk';
import { HDKey } from '@scure/bip32';
import { mnemonicToSeed } from '@scure/bip39';
const seed = await mnemonicToSeed('your 24-word seed phrase ...');
const rootNode = HDKey.fromMasterSeed(seed);
// With a known username
const result = await selectStxDerivation({
username: 'myname.btc',
rootNode,
index: 0,
network: 'mainnet',
});
console.log(result.stxDerivationType); // DerivationType.Wallet or DerivationType.Data
// Without a username — auto-discovers
const result2 = await selectStxDerivation({
rootNode,
index: 0,
network: 'mainnet',
});
console.log(result2.username); // discovered username or undefined
console.log(result2.stxDerivationType); // DerivationType.Wallet (default)Notes
Signature
Returns
Parameters
opts (required)
Property
Type
Required
Description
Last updated
Was this helpful?