Human Protocol SDK
v1.1.18
v1.1.18
  • Typescript SDK​
    • Encryption
      • Encryption
      • EncryptionUtils
    • Escrow
      • EscrowClient
      • EscrowUtils
    • KVStore
      • KVStoreClient
    • Staking
      • StakingClient
    • Storage
      • StorageClient
    • Statistics
      • StatisticsClient
  • Python SDK
    • agreement
      • bootstrap
      • measures
      • utils
    • encryption
      • encryption
      • legacy_encryption
      • encryption_utils
    • escrow
      • escrow_client
      • escrow_utils
    • kvstore
      • kvstore_client
    • staking
      • staking_client
      • staking_utils
    • statistics
      • statistics_client
    • storage
      • storage_client
      • storage_utils
    • constants
    • filter
    • utils
Powered by GitBook
On this page
  • Code Example
  • Module
  • class human_protocol_sdk.staking.staking_utils.LeaderData(chain_id, id, address, amount_staked, amount_allocated, amount_locked, locked_until_timestamp, amount_withdrawn, amount_slashed, reputation, reward, amount_jobs_launched, role=None, fee=None, public_key=None, webhook_url=None, url=None)
  • class human_protocol_sdk.staking.staking_utils.LeaderFilter(networks, role=None)
  • class human_protocol_sdk.staking.staking_utils.RewardData(escrow_address, amount)
  • class human_protocol_sdk.staking.staking_utils.StakingUtils
  1. Python SDK
  2. staking

staking_utils

Last updated 1 year ago

Utility class for staking-related operations.

Code Example

from human_protocol_sdk.constants import ChainId
from human_protocol_sdk.staking import StakingUtils, LeaderFilter

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

Module

class human_protocol_sdk.staking.staking_utils.LeaderData(chain_id, id, address, amount_staked, amount_allocated, amount_locked, locked_until_timestamp, amount_withdrawn, amount_slashed, reputation, reward, amount_jobs_launched, role=None, fee=None, public_key=None, webhook_url=None, url=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_launched, role=None, fee=None, public_key=None, webhook_url=None, url=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_launched (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

class human_protocol_sdk.staking.staking_utils.LeaderFilter(networks, role=None)

Bases: object

A class used to filter leaders.

__init__(networks, role=None)

Initializes a LeaderFilter instance.

  • Parameters:

    • role (Optional[str]) – Leader role

class human_protocol_sdk.staking.staking_utils.RewardData(escrow_address, amount)

Bases: object

__init__(escrow_address, amount)

Initializes an RewardData instance.

  • Parameters:

    • escrow_address (str) – Escrow address

    • amount (int) – Amount

class human_protocol_sdk.staking.staking_utils.StakingUtils

Bases: object

A utility class that provides additional staking-related functionalities.

static get_leader(chain_id, leader_address)

Get the leader details.

  • Parameters:

    • leader_address (str) – Address of the leader

  • Returns: Leader data if exists, otherwise None

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.staking import StakingUtils
    
    leader = StakingUtils.get_leader(
        ChainId.POLYGON_MUMBAI,
        '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
    )

static get_leaders(filter=<human_protocol_sdk.staking.staking_utils.LeaderFilter object>)

Get leaders data of the protocol

  • Returns: List of leaders data

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.staking import StakingUtils, LeaderFilter
    
    print(
        StakingUtils.get_leaders(
            LeaderFilter(networks=[ChainId.POLYGON_MUMBAI])
        )
    )

static get_rewards_info(chain_id, slasher)

Get rewards of the given slasher

  • Parameters:

    • slasher (str) – Address of the slasher

  • Returns: List of rewards info

  • Example:

    from human_protocol_sdk.constants import ChainId
    from human_protocol_sdk.staking import StakingUtils
    
    rewards_info = StakingUtils.get_rewards_info(
        ChainId.POLYGON_MUMBAI,
        '0x62dD51230A30401C455c8398d06F85e4EaB6309f'
    )

networks (List[]) – Networks to request data

chain_id () – Network in which the leader exists

Return type: Optional[]

Parameters: filter () – Leader filter

Return type: List[]

chain_id () – Network in which the slasher exists

Return type: List[]

LeaderData
LeaderFilter
LeaderData
RewardData
ChainId
ChainId
ChainId
ChainId