> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/reference/stacks.js/stacks-wallet/derivation/derivewalletkeys.md).

# deriveWalletKeys

Derives the root-level wallet keys from an HD root node. Returns the salt, root extended private key, and configuration private key.

***

### Usage

```ts
import { deriveWalletKeys } 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);

const walletKeys = await deriveWalletKeys(rootNode);

console.log(walletKeys.salt);            // hex string
console.log(walletKeys.rootKey);         // xprv... extended private key
console.log(walletKeys.configPrivateKey); // hex string
```

#### Notes

* This is called internally by `generateWallet`. You typically don't need to call it directly unless building custom wallet flows.
* The `salt` is derived from the identity keychain's public key and used for generating app-specific private keys.
* The `configPrivateKey` is derived from path `m/5757'/0'/1` and is used to encrypt wallet configuration data.

[**Reference Link**](https://github.com/stx-labs/stacks.js/tree/main/packages/wallet-sdk/src/derive.ts#L24)

***

### Signature

```ts
function deriveWalletKeys(rootNode: HDKey): Promise<WalletKeys>;
```

***

### Returns

`Promise<WalletKeys>`

```ts
interface WalletKeys {
  salt: string;
  rootKey: string;
  configPrivateKey: string;
}
```

***

### Parameters

#### rootNode (required)

* **Type**: `HDKey` (from `@scure/bip32`)

The root HD key derived from the wallet's seed phrase.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.stacks.co/reference/stacks.js/stacks-wallet/derivation/derivewalletkeys.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
