operator_utils
Utility class for operator-related operations.
Code Example
from human_protocol_sdk.constants import ChainId
from human_protocol_sdk.operator import OperatorUtils, OperatorFilter
print(
OperatorUtils.get_operators(
OperatorFilter(chain_id=ChainId.POLYGON_AMOY, roles=["Job Launcher"])
)
)Module
class human_protocol_sdk.operator.operator_utils.OperatorData(chain_id, id, address, amount_jobs_processed, reputation_networks, staked_amount=None, locked_amount=None, locked_until_timestamp=None, withdrawn_amount=None, slashed_amount=None, role=None, fee=None, public_key=None, webhook_url=None, website=None, url=None, job_types=None, registration_needed=None, registration_instructions=None, name=None, category=None)
Bases: object
__init__(chain_id, id, address, amount_jobs_processed, reputation_networks, staked_amount=None, locked_amount=None, locked_until_timestamp=None, withdrawn_amount=None, slashed_amount=None, role=None, fee=None, public_key=None, webhook_url=None, website=None, url=None, job_types=None, registration_needed=None, registration_instructions=None, name=None, category=None)
Initializes a OperatorData instance.
Parameters:
chain_id (
ChainId) – Chain Identifierid (
str) – Identifieraddress (
str) – Addressstaked_amount (
Optional[str]) – Amount stakedlocked_amount (
Optional[str]) – Amount lockedlocked_until_timestamp (
Optional[str]) – Locked until timestampwithdrawn_amount (
Optional[str]) – Amount withdrawnslashed_amount (
Optional[str]) – Amount slashedamount_jobs_processed (
str) – Amount of jobs launchedrole (
Optional[str]) – Rolefee (
Optional[str]) – Feepublic_key (
Optional[str]) – Public keywebhook_url (
Optional[str]) – Webhook URLwebsite (
Optional[str]) – Website URLurl (
Optional[str]) – URLjob_types (
Union[List[str],str,None]) – Job typesregistration_needed (
Optional[bool]) – Whether registration is neededregistration_instructions (
Optional[str]) – Registration instructionsreputation_networks (
Union[List[str],str]) – List of reputation networksname (
Optional[str]) – Namecategory (
Optional[str]) – Category
class human_protocol_sdk.operator.operator_utils.OperatorFilter(chain_id, roles=[], min_staked_amount=None, order_by=None, order_direction=OrderDirection.DESC, first=10, skip=0)
Bases: object
A class used to filter operators.
__init__(chain_id, roles=[], min_staked_amount=None, order_by=None, order_direction=OrderDirection.DESC, first=10, skip=0)
Initializes a OperatorFilter instance.
Parameters:
chain_id (
ChainId) – Chain ID to request dataroles (
Optional[str]) – Roles to filter bymin_staked_amount (
Optional[int]) – Minimum amount staked to filter byorder_by (
Optional[str]) – Property to order by, e.g., “role”order_direction (
OrderDirection) – Order direction of results, “asc” or “desc”first (
int) – Number of items per pageskip (
int) – Number of items to skip (for pagination)
class human_protocol_sdk.operator.operator_utils.OperatorUtils
Bases: object
A utility class that provides additional operator-related functionalities.
static get_operator(chain_id, operator_address, options=None)
Gets the operator details.
Parameters:
chain_id (
ChainId) – Network in which the operator existsoperator_address (
str) – Address of the operatoroptions (
Optional[SubgraphOptions]) – Optional config for subgraph requests
Return type:
Optional[OperatorData]Returns: Operator data if exists, otherwise None
Example:
static get_operators(filter, options=None)
Get operators data of the protocol.
Parameters:
filter (
OperatorFilter) – Operator filteroptions (
Optional[SubgraphOptions]) – Optional config for subgraph requests
Return type:
List[OperatorData]Returns: List of operators data
Example:
static get_reputation_network_operators(chain_id, address, role=None, options=None)
Get the reputation network operators of the specified address.
Parameters:
chain_id (
ChainId) – Network in which the reputation network existsaddress (
str) – Address of the reputation oraclerole (
Optional[str]) – (Optional) Role of the operatoroptions (
Optional[SubgraphOptions]) – Optional config for subgraph requests
Return type:
List[OperatorData]Returns: Returns an array of operator details
Example:
static get_rewards_info(chain_id, slasher, options=None)
Get rewards of the given slasher.
Parameters:
chain_id (
ChainId) – Network in which the slasher existsslasher (
str) – Address of the slasheroptions (
Optional[SubgraphOptions]) – Optional config for subgraph requests
Return type:
List[RewardData]Returns: List of rewards info
Example:
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 addressamount (
int) – Amount
Last updated