# createStake

## Description

The `createStake` function creates a new stake in a staking contract on the blockchain.&#x20;

It takes in several parameters including the amount of cryptocurrency to be staked, the duration of the stake, whether the stake is a liquidity provider (LP) stake and the user's private key

## Parameters

| Name         | Type   | Description                          |
| ------------ | ------ | ------------------------------------ |
| `amount`     | string | The amount of tokens to be staked.   |
| `duration`   | string | The duration of the stake in seconds |
| `isLp`       | string | Whether the stake is an LP stake     |
| `privateKey` | string | The private key of the user's wallet |

## Response

| Property  | Type   | Description                                                       |
| --------- | ------ | ----------------------------------------------------------------- |
| `receipt` | object | The transaction receipt object for the stake creation transaction |

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

```jsx
npm install @nest25/tokenomics-lib
OR
yarn add @nest25/tokenomics-lib
```

### Request

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

```javascript
// import Nest SDK library
const { staking } = require('@nest25/tokenomics-lib');
// private key of the account you want to use
const TEST_PRIVATE_KEY = 'your-private-key';
// create a new instance of staking
const Staking = new staking();
async function main() {
  // create a new stake
  const result = await Staking.createStake('1', '100', false, TEST_PRIVATE_KEY);
  // print the result
  console.log(result);
}
main();
```

### Response

```sh
 {
        type: 2,
        chainId: 8888,
        nonce: 71,
        maxPriorityFeePerGas: BigNumber { _hex: '0x59682f00', _isBigNumber: true },
        maxFeePerGas: BigNumber { _hex: '0xd09dc300', _isBigNumber: true },
        gasPrice: null,
        gasLimit: BigNumber { _hex: '0x03e562', _isBigNumber: true },
        to: '0x077e4F1496693B7c45128c436eF933ccaFe6d291',
        value: BigNumber { _hex: '0x00', _isBigNumber: true },
        data: '0x012cae390000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000',
        accessList: [],
        hash: '0x87fe62ca7a46c3bf264857c7073ae5d589ac15b237f9198023befab0b76540d9',
        v: 1,
        r: '0x6351d9d8fd124e736e1bca8142b6cd867dfa2ccfe33d284666eed512176807aa',
        s: '0x692c6c0f54976975f5159d420b5abc0ba28af70e21b457c1ba0db9af4968c488',
        from: '0x5712d28795106f0105C01e99A708d018C1d70E52',
        confirmations: 0,
        wait: [Function (anonymous)]
      }

```

## Use Cases

* **Crypto Staking Platforms:** The function can be used by crypto staking platforms to allow users to create new stakes in staking contracts on the blockchain.
* **Decentralized Finance (DeFi) Applications:** The function can be used by DeFi applications to enable users to stake their cryptocurrency and earn rewards on the blockchain.
* **Cryptocurrency Wallets:** The function can be used by cryptocurrency wallets to allow users to stake their cryptocurrency directly from their wallets.


---

# 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/tokenomics-sdk/createstake.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.
