# operator\_utils

Utility class for operator-related operations.

## Code Example

```python
from human_protocol_sdk.constants import ChainId
from human_protocol_sdk.operator import OperatorUtils, LeaderFilter

print(
    OperatorUtils.get_leaders(
        LeaderFilter(chain_id=ChainId.POLYGON_AMOY, roles=["Job Launcher"])
    )
)
```

## Module

### *class* human\_protocol\_sdk.operator.operator\_utils.LeaderData(chain\_id, id, address, amount\_staked, amount\_locked, locked\_until\_timestamp, amount\_withdrawn, amount\_slashed, reward, amount\_jobs\_processed, role=None, fee=None, public\_key=None, webhook\_url=None, website=None, url=None, job\_types=None, registration\_needed=None, registration\_instructions=None, reputation\_networks=None, name=None, category=None)

Bases: `object`

#### \_\_init\_\_(chain\_id, id, address, amount\_staked, amount\_locked, locked\_until\_timestamp, amount\_withdrawn, amount\_slashed, reward, amount\_jobs\_processed, role=None, fee=None, public\_key=None, webhook\_url=None, website=None, url=None, job\_types=None, registration\_needed=None, registration\_instructions=None, reputation\_networks=None, name=None, category=None)

Initializes a LeaderData instance.

* **Parameters:**
  * **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Chain Identifier
  * **id** (`str`) – Identifier
  * **address** (`str`) – Address
  * **amount\_staked** (`int`) – Amount staked
  * **amount\_locked** (`int`) – Amount locked
  * **locked\_until\_timestamp** (`int`) – Locked until timestamp
  * **amount\_withdrawn** (`int`) – Amount withdrawn
  * **amount\_slashed** (`int`) – Amount slashed
  * **reward** (`int`) – Reward
  * **amount\_jobs\_processed** (`int`) – Amount of jobs launched
  * **role** (`Optional`\[`str`]) – Role
  * **fee** (`Optional`\[`int`]) – Fee
  * **public\_key** (`Optional`\[`str`]) – Public key
  * **webhook\_url** (`Optional`\[`str`]) – Webhook URL
  * **website** (`Optional`\[`str`]) – Website URL
  * **url** (`Optional`\[`str`]) – URL
  * **job\_types** (`Optional`\[`List`\[`str`]]) – Job types
  * **registration\_needed** (`Optional`\[`bool`]) – Whether registration is needed
  * **registration\_instructions** (`Optional`\[`str`]) – Registration instructions
  * **reputation\_networks** (`Optional`\[`List`\[`str`]]) – List of reputation networks
  * **name** (`Optional`\[`str`]) – Name
  * **category** (`Optional`\[`str`]) – Category

### *class* human\_protocol\_sdk.operator.operator\_utils.LeaderFilter(chain\_id, roles=\[], min\_amount\_staked=None, order\_by=None, order\_direction=OrderDirection.DESC, first=10, skip=0)

Bases: `object`

A class used to filter leaders.

#### \_\_init\_\_(chain\_id, roles=\[], min\_amount\_staked=None, order\_by=None, order\_direction=OrderDirection.DESC, first=10, skip=0)

Initializes a LeaderFilter instance.

* **Parameters:**
  * **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Chain ID to request data
  * **roles** (`Optional`\[`str`]) – Roles to filter by
  * **min\_amount\_staked** (`Optional`\[`int`]) – Minimum amount staked to filter by
  * **order\_by** (`Optional`\[`str`]) – Property to order by, e.g., “role”
  * **order\_direction** ([`OrderDirection`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.OrderDirection)) – Order direction of results, “asc” or “desc”
  * **first** (`int`) – Number of items per page
  * **skip** (`int`) – Number of items to skip (for pagination)

### *class* human\_protocol\_sdk.operator.operator\_utils.Operator(address, role, url='', job\_types=\[], registration\_needed=None, registration\_instructions=None)

Bases: `object`

#### \_\_init\_\_(address, role, url='', job\_types=\[], registration\_needed=None, registration\_instructions=None)

Initializes an Operator instance.

* **Parameters:**
  * **address** (`str`) – Operator address
  * **role** (`str`) – Role of the operator
  * **url** (`str`) – URL of the operator
  * **job\_types** (`List`\[`str`]) – List of job types
  * **registration\_needed** (`Optional`\[`bool`]) – Whether registration is needed
  * **registration\_instructions** (`Optional`\[`str`]) – Registration instructions

### *class* human\_protocol\_sdk.operator.operator\_utils.OperatorUtils

Bases: `object`

A utility class that provides additional operator-related functionalities.

#### *static* get\_leader(chain\_id, leader\_address)

Gets the leader details.

* **Parameters:**
  * **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Network in which the leader exists
  * **leader\_address** (`str`) – Address of the leader
* **Return type:** `Optional`\[[`LeaderData`](#human_protocol_sdk.operator.operator_utils.LeaderData)]
* **Returns:** Leader data if exists, otherwise None
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.operator import OperatorUtils

  chain_id = ChainId.POLYGON_AMOY
  leader_address = '0x62dD51230A30401C455c8398d06F85e4EaB6309f'

  leader_data = OperatorUtils.get_leader(chain_id, leader_address)
  print(leader_data)
  ```

#### *static* get\_leaders(filter)

Get leaders data of the protocol.

* **Parameters:** **filter** ([`LeaderFilter`](#human_protocol_sdk.operator.operator_utils.LeaderFilter)) – Leader filter
* **Return type:** `List`\[[`LeaderData`](#human_protocol_sdk.operator.operator_utils.LeaderData)]
* **Returns:** List of leaders data
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.operator import OperatorUtils, LeaderFilter

  print(
      OperatorUtils.get_leaders(
          LeaderFilter(chain_id=ChainId.POLYGON_AMOY, roles=["Job Launcher"])
      )
  )
  ```

#### *static* get\_reputation\_network\_operators(chain\_id, address, role=None)

Get the reputation network operators of the specified address.

* **Parameters:**
  * **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Network in which the reputation network exists
  * **address** (`str`) – Address of the reputation oracle
  * **role** (`Optional`\[`str`]) – (Optional) Role of the operator
* **Return type:** `List`\[[`Operator`](#human_protocol_sdk.operator.operator_utils.Operator)]
* **Returns:** Returns an array of operator details
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.operator import OperatorUtils

  operators = OperatorUtils.get_reputation_network_operators(
      ChainId.POLYGON_AMOY,
      '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
  )
  print(operators)
  ```

#### *static* get\_rewards\_info(chain\_id, slasher)

Get rewards of the given slasher.

* **Parameters:**
  * **chain\_id** ([`ChainId`](https://sdk.humanprotocol.org/human-protocol-sdk/v4.0.1/human_protocol_sdk.constants#human_protocol_sdk.constants.ChainId)) – Network in which the slasher exists
  * **slasher** (`str`) – Address of the slasher
* **Return type:** `List`\[[`RewardData`](#human_protocol_sdk.operator.operator_utils.RewardData)]
* **Returns:** List of rewards info
* **Example:**

  ```python
  from human_protocol_sdk.constants import ChainId
  from human_protocol_sdk.operator import OperatorUtils

  rewards_info = OperatorUtils.get_rewards_info(
      ChainId.POLYGON_AMOY,
      '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
  )
  print(rewards_info)
  ```

### *exception* human\_protocol\_sdk.operator.operator\_utils.OperatorUtilsError

Bases: `Exception`

Raised when an error occurs while interacting with the operator.

### *class* human\_protocol\_sdk.operator.operator\_utils.RewardData(escrow\_address, amount)

Bases: `object`

#### \_\_init\_\_(escrow\_address, amount)

Initializes a RewardData instance.

* **Parameters:**
  * **escrow\_address** (`str`) – Escrow address
  * **amount** (`int`) – Amount
