# createWallet

## Description

The `createWallet` function generates a new mnemonic that can be used to create a new cryptocurrency wallet. The mnemonic is a randomly generated sequence of words that can be used to generate a hierarchical deterministic wallet, allowing for easy backup and recovery of the wallet.

## Parameters

This function does not take any parameters.&#x20;

## Response

| Field    | Data Type | Description                                                                                                                 |
| -------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `code`   | number    | Indicates whether the function was successful or not. A value of 1 indicates success, while a value of 0 indicates failure. |
| `result` | string    | If the code is 1, then this field contains the generated mnemonic. If the code is 0, then this field will be empty.         |
| `error`  | string    | If the code is 0, then this field contains the error message. If the code is 1, then this field will be empty.              |

## Example Request and Response

### Prerequisites&#x20;

Before making requests with Volary SDK, you must have it installed.

You can install Volary SDK using either **`npm`** or **`yarn`**. Use the following commands to install Volary SDK:

```sh
npm install @nest25/wallet-lib
OR
yarn add @nest25/wallet-lib
```

Next, install `tiny-secp256k1` npm package in order to create a new wallet:

```sh
npm install tiny-secp256k1
or 
yarn add tiny-secp256k1
```

### Request

Here is an example of how to make a `createWallet` request using the Volary SDK:

{% code overflow="wrap" %}

```javascript
// import Nest SDK
import { Wallet } from 'nest25/wallet-lib';
import * as ecc from 'tiny-secp256k1'; 

// Create a new instance of the Wallet class
const wallet = new Wallet(ecc); // Wallet class has 2 params: one is for ecc and the second one for environment (testnet , mainnet). By default, the value is set to testnet

const main = async () => {
  // Create a new wallet
  const response = await wallet.createWallet();
  // Log the response
  console.log('Response: ', response);
};

main();
```

{% endcode %}

### Response

{% code overflow="wrap" %}

```sh
{
        code: 1,
        result: 'forest almost like horn board swamp wish wedding rough number live                      when'
}
```

{% endcode %}

## Use Cases

* **Cryptocurrency Wallets:** This function can be used by cryptocurrency wallets to generate a new wallet and associated mnemonic for the user.
* **Blockchain Development:** This function can be used by developers building blockchain applications to generate new wallets for testing and development purposes.


---

# 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.volary.io/sdks-guide/blockchain-sdks/wallet-sdk/createwallet.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.
