# Generate a secret key

{% code fullWidth="false" expandable="true" %}

```typescript
import { generateSecretKey } from '@stacks/wallet-sdk';

// Generate a 24-word mnemonic (256 bits of entropy)
const mnemonic24 = generateSecretKey();
// Example: "aunt birth lounge misery utility blind holiday walnut fuel make gift parent gap picnic exact various express sphere family nerve oil drill engage youth"

// Generate a 12-word mnemonic (128 bits of entropy)
const mnemonic12 = generateSecretKey(128);
// Example: "winter crash infant long upset beauty cram tank short remain obtain sauce"
```

{% endcode %}

### Description

Create mnemonic seed phrases for wallet generation

### Use Cases

* Creating new wallet seed phrases
* Generating secure entropy for applications
* Building wallet creation flows
* Testing wallet functionality

### Key Concepts

* **Entropy** - Random data used to generate the phrase
* **Word count** - 12 words (128 bits) or 24 words (256 bits)
* **Word list** - Standardized list of 2048 words
* **Checksum** - Built-in error detection
* Mnemonic seed phrases follow the BIP39 standard


---

# Agent Instructions: 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:

```
GET https://docs.stacks.co/cookbook/stacks.js/accounts-and-addresses/generate-a-secret-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
