# Solana Staking

Instructions: <https://help.allnodes.com/en/articles/6612209-solana-staking-api>

## Get stake accounts

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

This endpoint allows you to get list of all your stake accounts.

#### 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 "SOL"                |
| action<mark style="color:red;">\*</mark>         | string | Must be "get-stake-accounts" |
| address<mark style="color:red;">\*</mark>        | string | Your wallet address          |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
  {
    publicKey: string;
    rentEpoch: number;
    lamports: number;
    stake: number;
    validatorPublicKey: string | null;
    status: {
      active: number;
      inactive: number;
      state: 'active' | 'inactive' | 'activating' | 'deactivating';
    };
  }
]
```

{% endtab %}
{% endtabs %}

## Create stake account

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

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

#### 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 "SOL"                  |
| action<mark style="color:red;">\*</mark>         | string | Must be "create-stake-account" |
| address<mark style="color:red;">\*</mark>        | string | Your wallet address            |
| amount<mark style="color:red;">\*</mark>         | string | Amount to stake                |

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

```json
{
  network: string;
  amount: string;
  serializedTransaction: string;
  stakeAccountSecretKey: string;
  stakeAccountPublicKey: string;
}
```

{% endtab %}

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

```json
{
  "error": "ACCOUNT_DOES_NOT_EXIST"
}
```

{% endtab %}
{% endtabs %}

## 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 delegating staked coins to Allnodes validator.

#### 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 "SOL"                                                                                  |
| action<mark style="color:red;">\*</mark>                | string | Must be "stake"                                                                                |
| address<mark style="color:red;">\*</mark>               | string | Your wallet address                                                                            |
| stakeAccountPublicKey<mark style="color:red;">\*</mark> | string | Public key of your stake account. Public key can be extracted from "Create stake account" call |

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

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

{% endtab %}

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

```json
{
  "error": "INVALID_ADDRESS"
}
```

{% endtab %}
{% endtabs %}

## Unbond coins

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

This endpoint allows you to get serialized unsigned transaction for unbonding coins (deactivating your stake account).

#### 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 "SOL"                                                                                  |
| action<mark style="color:red;">\*</mark>                | string | Must be "unbond-stake"                                                                         |
| address<mark style="color:red;">\*</mark>               | string | Your wallet address                                                                            |
| stakeAccountPublicKey<mark style="color:red;">\*</mark> | string | Public key of your stake account. Public key can be extracted from "Create stake account" call |

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

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

{% endtab %}

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

```javascript
{
  "error": "INVALID_ADDRESS"
}
```

{% 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.

#### 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 "SOL"                                                                                  |
| action<mark style="color:red;">\*</mark>                | string | Must be "withdraw-stake"                                                                       |
| address<mark style="color:red;">\*</mark>               | string | Your wallet address                                                                            |
| stakeAccountPublicKey<mark style="color:red;">\*</mark> | string | Public key of your stake account. Public key can be extracted from "Create stake account" call |
| amount<mark style="color:red;">\*</mark>                | string | Amount to withdraw                                                                             |

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

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

{% endtab %}

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

```javascript
{
  "error": "NOT_SPECIFIED_AMOUNT"
}
```

{% 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/sol/solana-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.
