# 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 %}
