# The Graph Staking

## Approve a token

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

This endpoint allows you to get transaction params for approve tokens.

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

{% tabs %}
{% tab title="200 Transaction params successfully generated." %}

```
{
  network: string;
  toAddress: string;
  amount: string;
  gasLimit: number;
  gasPrice: number;
  data: string;
}
```

{% endtab %}

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

```
{
  "error": "TOKEN_ALREADY_APPROVED"
}
```

{% endtab %}

{% tab title="404 Example of error response." %}

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

{% endtab %}
{% endtabs %}

## Stake coins/tokens

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

This endpoint allows you to get transaction params for staking coins/tokens to Allnodes indexer.

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

{% tabs %}
{% tab title="200 Transaction params successfully generated." %}

```
{
  network: string;
  toAddress: string;
  amount: string;
  gasLimit: number;
  gasPrice: number;
  data: string;
}
```

{% endtab %}

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

```
{
  "error": "NOT_ENOUGH_TOKENS"
}
```

{% endtab %}

{% tab title="404 Example of error response." %}

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

{% endtab %}
{% endtabs %}

## Unbond coins/tokens

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

This endpoint allows you to get transaction params for unbonding coins/tokens from Allnodes indexer.

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

{% tabs %}
{% tab title="200 Transaction params successfully generated." %}

```
{
  network: string;
  toAddress: string;
  amount: string;
  gasLimit: number;
  gasPrice: number;
  data: string;
}
```

{% endtab %}

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

```
{
  "error": "NOT_ENOUGH_TOKENS"
}
```

{% endtab %}

{% tab title="404 Example of error response." %}

```
{
  "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 transaction params for withdraw stake from Allnodes indexer. \
\
**Unbonding period**: 28 epochs (28 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 "GRT"            |
| action<mark style="color:red;">\*</mark>         | string | Must be "withdraw-stake" |
| address<mark style="color:red;">\*</mark>        | string | Your wallet address      |

{% tabs %}
{% tab title="200 Transaction params successfully generated." %}

```
{
  network: string;
  toAddress: string;
  amount: string;
  gasLimit: number;
  gasPrice: number;
  data: string;
}
```

{% endtab %}

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

```
{
  "error": "NOT_ENOUGH_EPOCHS_PASSED"
}
```

{% endtab %}

{% tab title="404 Example of error response." %}

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

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