# Hosted operator API (BLS based)

## Overview

The AltLayer-hosted operator comes with APIs. With the APIs, AVS only needs to design and implement its business logic. The API will handle the signature signing and submission to the aggregator.&#x20;

<figure><img src="/files/cQRF7tHP6pXeZJWOqEbS" alt=""><figcaption></figcaption></figure>

To interact with the API, there are two options

1. Interact with the managed operator&#x20;
2. Interact with the managed operator proxy

## The rationale of operator proxy

While direct interaction with the operator provides the most significant degree of flexibility, it is often necessary to construct the parameters, which can be low-level.&#x20;

Let's use the following example to illustrate it

```solidity
    function confirmMessage(
        Params1 p1,
        ...
        ParamsN pN,
        NonSignerStakesAndSignature memory nonSignerStakesAndSignature
    ) external whenNotPaused onlyConfirmer {
    ...
    }

```

The operator API has a parameter called `params_raw`. This is the abi-encoded bytes of `p1....pN`. It can be complex to construct the encoded bytes.

The managed operator proxy abstracted away the complexity. It supports any AVS using the [task manager convention](https://github.com/Layr-Labs/incredible-squaring-avs/blob/master/contracts/src/IncredibleSquaringTaskManager.sol). When using the operator proxy API, there is no need to compute `param_raw`. The AVS builder can focus on providing the actual payload.  As such, the API is much simpler and easier to use.&#x20;

## Getting the operator and/or operator proxy endpoint and credentials

Go to the operator section and click on the menu button for "Hosted Operator Service".

<figure><img src="/files/K4qGhyA6nPv19kXBNBBf" alt=""><figcaption></figcaption></figure>

Click on the "Credentials" link to display the endpoints, username and password. The username and password are required as the operator and operator proxy API have basic access authentication enabled.&#x20;

<figure><img src="/files/2G5TpG2UWCv959dkJoIK" alt=""><figcaption></figcaption></figure>

## Operator API

### Request header

* Content-Type: application/json
* Authorization: Basic \<base64 encoded of admin`:password`>

### Request body

```json
{
  "id": "1",
  "jsonrpc": "2.0",
  "method": "operator_createSigTask",
  "params": [
    {
      "avs_name": "op",
      "method": "tt",
      "params_raw": "0x00",
      "reference_block_number": 1000,
      "quorum_numbers": [
        0
      ],
      "quorum_threshold_percentages": [
        66
      ],
      "sig_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }
  ]
}
```

* `method`: operator\_createSigTask. This is the API method and should not be changed
* `params.avs_name`: name of the AVS
* `params.method`: the smart contract method that handled the contract call from the aggregator e.g `respondToTask`
* `params.param_raw`: the abi-encoded call data. It can be all calldata or a subset of the calldata
* `params.reference_block_number`: reference block number for quorum\_numbers and quorum\_threshold\_percentages&#x20;
* `params.quorum_numbers` : quorum number in which operators have signed for
* `params.quorum_threshold_percentages` : quorum threshold for the particular quorum number
* `params.sig_hash` : the signed hash of `param_raw`

### Sample curl request&#x20;

{% hint style="info" %}
Remember to update&#x20;

1. basic auth credentials
2. avs name
3. method
4. params
5. operator endpoint
   {% endhint %}

```bash
curl --noproxy '*' \
  -H "Content-Type: application/json" \
  --header 'Authorization: Basic <base64 encoded admin:password>' 
  -d '{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "operator_createSigTask",
    "params": [
      {
        "avs_name": "op",
        "method": "tt",
        "params_raw": "0x00",
        "reference_block_number": 1000,
        "quorum_numbers": [0],
        "quorum_threshold_percentages": [66],
        "sig_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
      }
    ]
  }' \
  https://your-avs-operator.alt.technology

```

## Operator Proxy API

### Request header

* Content-Type: application/json
* Authorization: Basic \<base64 encoded of admin`:password`>

### Request body

```bash
{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "operator_createSigTaskResponse",
    "params": [
        {
            "method": "respondToRequest",
            "task_created_block": 3003011,
            "message": "0x00",
            "task_index": 100,
            "resp_message": "0x0000"
        }
    ]
}
```

* `method`: operator\_createSigTaskResponse. This is the API method and should not be changed
* `params`.method: the smart contract method that handled the contract call from the aggregator, e.g `respondToTask`
* `params.task_created_block`: the block number in which the task is created
* `params.message`: the task message found inside the Task struct
* `params.task_index`: the task index in the smart contract&#x20;
* `params.resp_message`: the response message for the task

### Sample curl request&#x20;

{% hint style="info" %}
Remember to update&#x20;

1. basic auth credentials
2. params
3. operator proxy endpoint
   {% endhint %}

```bash
curl --noproxy '*' -H "Content-Type: application/json" --header 'Authorization: Basic <base64 encoded admin:password>' \
-d '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "operator_createSigTaskResponse",
    "params": [
        {
            "method": "respondToRequest",
            "task_created_block": 3003011,
            "message": "0x00",
            "task_index": 100,
            "resp_message": "0x0000"
        }
    ]
}' \
https://your-avs.alt.technology
```

### Sample success response

```json
{
    "jsonrpc": "2.0",
    "id": 2,
    "result": {
        "task_index": 1,
        "tx_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "sig_hash": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }
}
```


---

# 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.altlayer.io/altlayer-documentation/wizard/hosted-operator-api-bls-based.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.
