# fetchWalletFromPrivateKey

## Description

The `fetchWalletfromPrivateKey` function generates a key pair (public key and private key) from a given private key. It makes use of the CasperClient library and the Ed25519 algorithm to generate the key pair.

## Parameters

| Name         | Type   | Description                                         |
| ------------ | ------ | --------------------------------------------------- |
| `privateKey` | string | The private key to be used to generate the key pair |
| `RPC_API`    | string | The RPC API to be used by the CasperClient          |

## Response

| Name      | Type   | Description                                                              |
| --------- | ------ | ------------------------------------------------------------------------ |
| `keyPair` | object | An object containing the generated public key and private key as buffers |

## Example Request and Response

### Prerequisites

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/casper-lib
OR
yarn add @nest25/casper-lib
```

### Request

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

````javascript
// import Nest25 Casper library
const { Casper } = require('@nest25/casper-lib');
// create a new Casper instance
const casper = new Casper();

// set testnet variables
const privateKey = 'your-private-key';
const RPC_API = 'https://rpc.testnet.casperlabs.io/rpc';

async function main() {
  // fetch wallet from private key
  let { keyPair } = await casper.fetchWalletfromPrivateKey(privateKey, RPC_API);
  console.log(keyPair);
}
// call main function
main();

```
````

### Response

```sh
  {
        keyPair: t {
          publicKey: t { isCLValue: true, data: [Uint8Array], tag: 1 },
          privateKey: Uint8Array(64) [
            136, 103,  79,  12,  53,  66, 163, 104,  97, 238, 253,
            201,  63, 217,  28, 226,   8,  28, 163, 193, 111, 158,
            233, 203, 206, 234, 204, 112,  91, 196, 214, 176,  58,
             21, 106,  80, 252,  98, 132, 186,  67, 106, 237, 234,
            249, 107,  85, 172,  26,  12,  87, 238, 159, 138,  70,
            191,  28, 101,  24, 175, 233, 178, 245, 108
          ],
          signatureAlgorithm: 'ed25519'
        }
      }
```

## Use Cases

* **Crypto Wallets:** The function can be used by crypto wallets to generate key pairs from private keys.
* **Blockchain Applications:** The function can be used by blockchain applications to interact with the Casper network and sign transactions with generated key pairs.

<br>


---

# 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/casper-sdk/fetchwalletfromprivatekey.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.
