> For the complete documentation index, see [llms.txt](https://docs.non-obvious.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.non-obvious.ai/sdks-guide/blockchain-sdks/tokenomics-sdk/removestake.md).

# removeStake

## Description

The `removeStake` function allows users to remove a previously staked amount from a staking contract and returns a transaction receipt upon successful execution.&#x20;

## Parameters

| Name         | Type   | Description                                     |
| ------------ | ------ | ----------------------------------------------- |
| `stakeId`    | number | The ID of the stake to be removed               |
| `amount`     | string | The amount of the stake to be removed           |
| `privateKey` | string | The user's private key for the staking contract |

## Response

<table><thead><tr><th>Property</th><th width="92">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>receipt</code></td><td>object</td><td>The transaction receipt object </td></tr></tbody></table>

## Example Request and Response

### Prerequisites

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

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

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

### Request

Here is an example of how to make a `removeStake` request using the NO.AI 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() {
  // call removeStake function
  const result = await Staking.removeStake(2, '1', TEST_PRIVATE_KEY);
  // print the result
  console.log(result);
}
main();

```

### Response

```
{
        type: 2,
        chainId: 8888,
        nonce: 72,
        maxPriorityFeePerGas: BigNumber { _hex: '0x59682f00', _isBigNumber: true },
        maxFeePerGas: BigNumber { _hex: '0xd09dc300', _isBigNumber: true },
        gasPrice: null,
        gasLimit: BigNumber { _hex: '0x07b123', _isBigNumber: true },
        to: '0x077e4F1496693B7c45128c436eF933ccaFe6d291',
        value: BigNumber { _hex: '0x00', _isBigNumber: true },
        data: '0x2d67f0b900000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a7640000',
        accessList: [],
        hash: '0x608b1c3a7af858d091c1717534d0a740988a3748027dd1eefcc5a9baaca69cac',
        v: 0,
        r: '0xde2811060e6cbec614ba797dee12314a0afed55c0e2e8cd40390652a46cad725',
        s: '0x21e7e26e4973e69c3c19a007cc154e2aa26fead25f74809cb1e3e3cca4ebb705',
        from: '0x5712d28795106f0105C01e99A708d018C1d70E52',
        confirmations: 0,
        wait: [Function (anonymous)]
      }
```

## Use Cases

* **Staking Platforms:** The function can be used by staking platforms to allow users to remove their staked tokens and receive rewards.
* **DeFi Applications:** The function can be used by DeFi applications that implement staking features to allow users to withdraw their staked tokens.
* **Blockchain-based Games:** The function can be used by blockchain-based games that offer staking mechanics to enable players to remove their staked tokens as needed.


---

# 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.non-obvious.ai/sdks-guide/blockchain-sdks/tokenomics-sdk/removestake.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.
