# Masternode

## Host a masternode

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

This endpoint allows you to host new masternode.

#### Headers

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

#### Request Body

| Name            | Type   | Description                    |
| --------------- | ------ | ------------------------------ |
| currencySymbol  | string | Must be "SYS"                  |
| collateralHash  | string | Hash of your collateral UTXO   |
| collateralIndex | number | Index of your collateral UTXO  |
| nodeName        | string | Name of your new masternode    |
| walletType      | string | "ledger" \| "trezor" \| "core" |

{% tabs %}
{% tab title="201 Masternode was successfully hosted." %}

```typescript
{
  id: string;
  ip: string;
  name: string;
  currencySymbol: string;
  createdAt: string;
  payoutFrequencySeconds: number | null;
  apr: string | null;
  instance: {
    version: string;
    status: string;
    uptimeSeconds: number | null;
    lastSeenAt: string | null;
  };
  address: {
    collateralAddress: string;
    collateralHash: string;
    collateralIndex: number;
    payeeAddress: string;
    balanceAmount: number;
    rewardsEarned: number;
    lastRewardAt: string | null;
  };
  settings: {
    walletType: 'ledger' | 'trezor' | 'core' | null;
  };
}
```

{% endtab %}

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

```javascript
{
  "error": "INVALID_CURRENCY_SYMBOL"
}
```

{% endtab %}
{% endtabs %}

## Get UTXO

<mark style="color:blue;">`GET`</mark> `https://www.allnodes.com/api/v1/node/utxo/{address}`

This endpoint allows you to get list of all your collateral utxo.

#### Path Parameters

| Name                                      | Type   | Description             |
| ----------------------------------------- | ------ | ----------------------- |
| address<mark style="color:red;">\*</mark> | string | Your collateral address |

#### Headers

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

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

```
[
  {
    hash: string;
    index: number;
  }
]
```

{% endtab %}
{% endtabs %}

## Get hosting state

<mark style="color:blue;">`GET`</mark> `https://www.allnodes.com/api/v1/node/state/{hash}-{index}`

This endpoint allows you to get hosting state of your collateral utxo.

#### Path Parameters

| Name                                    | Type   | Description                |
| --------------------------------------- | ------ | -------------------------- |
| hash<mark style="color:red;">\*</mark>  | string | Your collateral UTXO hash  |
| index<mark style="color:red;">\*</mark> | number | Your collateral UTXO index |

#### Headers

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

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

```
{
  isAlreadyHosted: boolean;
  isAlreadyHostedOnAllnodes: boolean;
  isActivated: boolean;
  isBanned: boolean;
}
```

{% endtab %}

{% tab title="400 " %}

```
{
  "error": "INVALID_COLLATERAL_HASH_AND_INDEX"
}
```

{% endtab %}
{% endtabs %}

## Execute "protx register\_prepare" command and get output

<mark style="color:blue;">`GET`</mark> `https://www.allnodes.com/api/v1/node/{id}/deterministic/prepare`

This endpoint allows you to get results of "protx register\_submit" command executed on our full node.

#### Path Parameters

| Name                                 | Type   | Description                                                                  |
| ------------------------------------ | ------ | ---------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | Node you want to register. ID can be extracted from the “Get all nodes” call |

#### Query Parameters

| Name         | Type   | Description                              |
| ------------ | ------ | ---------------------------------------- |
| payeeAddress | string | Address for receiving masternode rewards |

#### Headers

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

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

```
{
  tx: string;
  collateralAddress: string;
  signMessage: string;
}
```

{% endtab %}

{% tab title="400 " %}

```
{
  "error": "INVALID_PAYEE_ADDRESS"
}
```

{% endtab %}
{% endtabs %}

## Execute "protx register\_submit" command

<mark style="color:green;">`POST`</mark> `https://www.allnodes.com/api/v1/node/{id}/deterministic/submit`

This endpoint allows you to execute "protx register\_submit" command on our full node with data provided through the API call. Registration in deterministic list will happen in 1 block after execution.

#### Path Parameters

| Name                                 | Type   | Description                                                                  |
| ------------------------------------ | ------ | ---------------------------------------------------------------------------- |
| id<mark style="color:red;">\*</mark> | string | Node you want to register. ID can be extracted from the “Get all nodes” call |

#### Headers

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

#### Request Body

| Name      | Type   | Description                                                      |
| --------- | ------ | ---------------------------------------------------------------- |
| signature | string | Signed "signMessage" from protx register\_prepare command output |
| tx        | string | "tx" from protx register\_prepare command output                 |

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

```
{
  hash: string;
}
```

{% endtab %}

{% tab title="400 " %}

```
{
  "error": "INVALID_SIGNATURE"
}
```

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