Human Protocol SDK
v3.0.6
v3.0.6
  • Typescript SDK
    • Encryption
      • Encryption
      • EncryptionUtils
    • Escrow
      • EscrowClient
      • EscrowUtils
    • KVStore
      • KVStoreClient
      • KVStoreUtils
    • Staking
      • StakingClient
    • Operator
      • OperatorUtils
    • Storage
      • StorageClient
    • Statistics
      • StatisticsClient
    • Transaction
      • TransactionUtils
  • Python SDK
    • agreement
      • bootstrap
      • measures
      • utils
    • encryption
      • encryption
      • legacy_encryption
      • encryption_utils
    • escrow
      • escrow_client
      • escrow_utils
    • kvstore
      • kvstore_client
      • kvstore_utils
    • staking
      • staking_client
      • staking_utils
    • operator
      • operator_utils
    • statistics
      • statistics_client
    • storage
      • storage_client
      • storage_utils
    • transaction
      • transaction_utils
    • constants
    • filter
    • utils
  • CHANGELOG
Powered by GitBook
On this page
  • Code Example
  • Module
  • class human_protocol_sdk.operator.operator_utils.LeaderData(chain_id, id, address, amount_staked, amount_allocated, amount_locked, locked_until_timestamp, amount_withdrawn, amount_slashed, reputation, reward, amount_jobs_processed, role=None, fee=None, public_key=None, webhook_url=None, url=None, job_types=None, registration_needed=None, registration_instructions=None)
  • class human_protocol_sdk.operator.operator_utils.LeaderFilter(chain_id, role=None)
  • class human_protocol_sdk.operator.operator_utils.Operator(address, role, url='', job_types=[], registration_needed=None, registration_instructions=None)
  • class human_protocol_sdk.operator.operator_utils.OperatorUtils
  • exception human_protocol_sdk.operator.operator_utils.OperatorUtilsError
  • class human_protocol_sdk.operator.operator_utils.RewardData(escrow_address, amount)
  1. Python SDK
  2. operator

operator_utils

Last updated 6 months ago

Utility class for operator-related operations.

Code Example

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

print(
    OperatorUtils.get_leaders(
        LeaderFilter(networks=[ChainId.POLYGON_AMOY], role="Job Launcher")
    )
)

Module

class human_protocol_sdk.operator.operator_utils.LeaderData(chain_id, id, address, amount_staked, amount_allocated, amount_locked, locked_until_timestamp, amount_withdrawn, amount_slashed, reputation, reward, amount_jobs_processed, role=None, fee=None, public_key=None, webhook_url=None, url=None, job_types=None, registration_needed=None, registration_instructions=None)

Bases: object

__init__(chain_id, id, address, amount_staked, amount_allocated, amount_locked, locked_until_timestamp, amount_withdrawn, amount_slashed, reputation, reward, amount_jobs_processed, role=None, fee=None, public_key=None, webhook_url=None, url=None, job_types=None, registration_needed=None, registration_instructions=None)

Initializes an LeaderData instance.

  • Parameters:

    • chain_id () – Chain Identifier

    • id (str) – Identifier

    • address (str) – Address

    • amount_staked (int) – Amount staked

    • amount_allocated (int) – Amount allocated

    • amount_locked (int) – Amount locked

    • locked_until_timestamp (int) – Locked until timestamp

    • amount_withdrawn (int) – Amount withdrawn

    • amount_slashed (int) – Amount slashed

    • reputation (int) – Reputation

    • 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

    • url (Optional[str]) – Url

    • job_types (Optional[List[str]]) – Job types

    • registration_needed (Optional[bool]) – True,

    • registration_instructions (Optional[str]) – Instructions url,

class human_protocol_sdk.operator.operator_utils.LeaderFilter(chain_id, role=None)

Bases: object

A class used to filter leaders.

__init__(chain_id, role=None)

Initializes a LeaderFilter instance.

  • Parameters:

    • role (Optional[str]) – Leader role

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

    • registration_needed (Optional[bool]) – True,

    • registration_instructions (Optional[str]) – Instructions url,

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)

Get the leader details.

  • Parameters:

    • leader_address (str) – Address of the leader

  • Return type: Optional[LeaderData]

  • Returns: Leader data if exists, otherwise None

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.operator import OperatorUtils
    
    leader = OperatorUtils.get_leader(
        ChainId.POLYGON_AMOY,
        '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
    )

static get_leaders(filter)

Get leaders data of the protocol

  • Parameters: filter (LeaderFilter) – Leader filter

  • Return type: List[LeaderData]

  • Returns: List of leaders data

  • Example:

    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)
        )
    )

static get_reputation_network_operators(chain_id, address, role=None)

Get the reputation network operators of the specified address.

  • Parameters:

    • address (str) – Address of the reputation oracle

    • role (Optional[str]) – (Optional) Role of the operator

  • Return type: List[Operator]

  • Returns: Returns an array of operator details

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.operator import OperatorUtils
    
    leader = OperatorUtils.get_reputation_network_operators(
        ChainId.POLYGON_AMOY,
        '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
    )

static get_rewards_info(chain_id, slasher)

Get rewards of the given slasher

  • Parameters:

    • slasher (str) – Address of the slasher

  • Return type: List[RewardData]

  • Returns: List of rewards info

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.operator import OperatorUtils
    
    rewards_info = OperatorUtils.get_rewards_info(
        ChainId.POLYGON_AMOY,
        '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
    )

exception human_protocol_sdk.operator.operator_utils.OperatorUtilsError

Bases: Exception

Raises when some error happens when interacting with 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

chain_id () – Chain Id to request data

chain_id () – Network in which the leader exists

chain_id () – Network in which the reputation network exists

chain_id () – Network in which the slasher exists

ChainId
ChainId
ChainId
ChainId
ChainId