Closed mits87 closed 2 years ago
@Vritra4 I saw that before but still I can't see a clear solution for that. Let me give an example how I'm creating child wallets for BSC:
const { hdkey } = require('ethereumjs-wallet');
const bip39 = require('bip39');
const mnemonic = 'XXX';
bip39.mnemonicToSeed(mnemonic).then((seed) => {
const hdWallet = hdkey.fromMasterSeed(seed);
const masterNode = hdWallet.derivePath("m/44'/60'/0'/0");
const mainWallet = hdkey.fromExtendedKey(masterNode.privateExtendedKey());
const node = mainWallet.derivePath("m/0");
console.log("Main Wallet / Account");
console.log('Address:', node.getWallet().getAddressString());
const childHdWallet = hdkey.fromExtendedKey(node.privateExtendedKey());
const childHdNode = childHdWallet.derivePath("m/44'/60'/0'/0");
const childWallet = hdkey.fromExtendedKey(childHdNode.publicExtendedKey());
const childNode = childWallet.derivePath("m/1");
console.log("Child (USER) Wallet / Account");
console.log('address:', childNode.getWallet().getAddressString());
});
As you can see all nested wallets (child wallets) are creating based on the previous public / private extended key. How can I do that with terra-js?
i don't think there's a way to create child wallet based on previous key.. https://docs.terra.money/SDKs/Terra-js/Keys.html#specifying-hd-path needs whole hdpath i guess.
Hi there,
Currently I can easily create a new wallet using the SDK:
which works great!
But I would like to generate Hierarchical Deterministic wallets (child wallets) in a similar way how BSC is allowing.
Do you know how can achieve it using SDK?