# NEAR Protocol Staking

Instructions: <https://help.allnodes.com/en/articles/6759442-near-protocol-staking-api>

## Stake coins

<mark style="color:green;">`POST`</mark> `https://www.allnodes.com/api/v1/staking`

This endpoint allows you to get serialized unsigned transaction for staking coins.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer TOKEN |

#### Request Body

| Name                                               | Type   | Description                                                                              |
| -------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| currencySymbol<mark style="color:red;">\*</mark>   | string | Must be "NEAR"                                                                           |
| action<mark style="color:red;">\*</mark>           | string | Must be "stake"                                                                          |
| accountID<mark style="color:red;">\*</mark>        | string | You wallet ID (Example: "allnodes.near")                                                 |
| accountPublicKey<mark style="color:red;">\*</mark> | string | Your wallet public key (Example: "ed25519:1sTWdHCPJL3xkzxdg4ZkQm4d8A4TakDePXbpaGh4dAVE") |
| amount<mark style="color:red;">\*</mark>           | string | Amount to stake (in NEAR)                                                                |
| validatorID<mark style="color:red;">\*</mark>      | string | Validator ID to delegate (Example: "allnodes.poolv1.near")                               |

{% tabs %}
{% tab title="200: OK Serialized transaction successfully generated." %}

```javascript
{
  serializedTransaction: string;
}
```

{% endtab %}

{% tab title="400: Bad Request Example of error response." %}

```javascript
{
  "error": "INVALID_ACCOUNT_ID"
}
```

{% endtab %}
{% endtabs %}

## Unbond coins

<mark style="color:green;">`POST`</mark> `https://www.allnodes.com/api/v1/staking`

This endpoint allows you to get serialized unsigned transaction for unbonding coins.

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer TOKEN |

#### Request Body

| Name                                               | Type   | Description                                                                              |
| -------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| currencySymbol<mark style="color:red;">\*</mark>   | string | Must be "NEAR"                                                                           |
| action<mark style="color:red;">\*</mark>           | string | Must be "unbond"                                                                         |
| accountID<mark style="color:red;">\*</mark>        | string | You wallet ID (Example: "allnodes.near")                                                 |
| accountPublicKey<mark style="color:red;">\*</mark> | string | Your wallet public key (Example: "ed25519:1sTWdHCPJL3xkzxdg4ZkQm4d8A4TakDePXbpaGh4dAVE") |
| validatorID<mark style="color:red;">\*</mark>      | string | Validator ID to unbond from (Example: "allnodes.poolv1.near")                            |

{% tabs %}
{% tab title="200: OK Serialized transaction successfully generated." %}

```javascript
{
  serializedTransaction: string;
}
```

{% endtab %}

{% tab title="400: Bad Request Example of error response." %}

```javascript
{
  "error": "INVALID_VALIDATOR_ID"
}
```

{% endtab %}
{% endtabs %}

## Withdraw stake (after unbonding period finished)

<mark style="color:green;">`POST`</mark> `https://www.allnodes.com/api/v1/staking`

This endpoint allows you to get serialized unsigned transaction for withdraw stake.

**Unbonding period**: 2 days

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer TOKEN |

#### Request Body

| Name                                               | Type   | Description                                                                              |
| -------------------------------------------------- | ------ | ---------------------------------------------------------------------------------------- |
| currencySymbol<mark style="color:red;">\*</mark>   | string | Must be "NEAR"                                                                           |
| action<mark style="color:red;">\*</mark>           | string | Must be "withdraw-stake"                                                                 |
| accountID<mark style="color:red;">\*</mark>        | string | You wallet ID (Example: "allnodes.near")                                                 |
| accountPublicKey<mark style="color:red;">\*</mark> | string | Your wallet public key (Example: "ed25519:1sTWdHCPJL3xkzxdg4ZkQm4d8A4TakDePXbpaGh4dAVE") |
| validatorID<mark style="color:red;">\*</mark>      | string | Validator ID to withdraw stake from (Example: "allnodes.poolv1.near")                    |

{% tabs %}
{% tab title="200: OK Serialized transaction successfully generated." %}

```javascript
{
  serializedTransaction: string;
}
```

{% endtab %}

{% tab title="400: Bad Request Example of error response." %}

```javascript
{
  "error": "INVALID_PUBLIC_KEY"
}
```

{% endtab %}
{% endtabs %}


---

# 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.allnodes.com/near/staking.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.
