Staking

API

class terra_sdk.client.lcd.api.staking.StakingAPI(c)[source]
bonded_validators(delegator)[source]

Fetches the list of validators a delegator is currently delegating to.

Parameters

delegator (AccAddress) – delegator account address

Returns

currently bonded validators

Return type

List[Validator]

delegation(delegator, validator)[source]

Fetch a single delegation via a delegator, validator pair.

Parameters
  • delegator (AccAddress) – delegator account address

  • validator (ValAddress) – validator operator address

Returns

delegation

Return type

Delegation

delegations(delegator=None, validator=None)[source]

Fetches current delegations, filtering by delegator, validator, or both.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator (Optional[ValAddress], optional) – validator operator address.

Raises

TypeError – if both delegator and validator are None.

Returns

delegations

Return type

List[Delegation]

parameters()[source]

Fetch Staking module parameters.

Returns

Staking module parameters

Return type

dict

pool()[source]

Fetch current staking pool information.

Returns

information about current staking pool

Return type

StakingPool

redelegations(delegator=None, validator_src=None, validator_dst=None)[source]

Fetch redelgations.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator_src (Optional[ValAddress], optional) – source validator operator address (from).

  • validator_dst (Optional[ValAddress], optional) – dest. validator operator address (to).

Returns

redelegations

Return type

List[Redelegation]

unbonding_delegation(delegator, validator)[source]

Fetch a single undelegation via a delegator, validator pair.

Parameters
  • delegator (AccAddress) – delegator account address

  • validator (ValAddress) – validator operator address

Returns

undelegation

Return type

UnbondingDelegation

unbonding_delegations(delegator=None, validator=None)[source]

Fetches current undelegations, filtering by delegator, validator, or both.

Parameters
  • delegator (Optional[AccAddress], optional) – delegator account address.

  • validator (Optional[ValAddress], optional) – validator operator address.

Raises

TypeError – if both delegator and validator are None.

Returns

undelegations

Return type

List[UnbondingDelegation]

validator(validator)[source]

Fetch information about a single validator.

Parameters

validator (ValAddress) – validator operator address

Returns

validator information

Return type

Validator

validators()[source]

Fetch information of all validators.

Returns

validator informations

Return type

List[Validator]

Data

Delegation

class terra_sdk.core.staking.data.delegation.Delegation(delegator_address, validator_address, shares, balance)[source]

Contains information about a current delegation pair (delegator_address, validator_address)

balance: terra_sdk.core.coin.Coin
delegator_address: AccAddress
shares: terra_sdk.core.numeric.Dec
validator_address: ValAddress
class terra_sdk.core.staking.data.delegation.Redelegation(delegator_address, validator_src_address, validator_dst_address, entries)[source]

Contains informations about a redelgation for delegation tuple (delegator_address, validator_src_address, validator_dst_address)

delegator_address: AccAddress
entries: List[terra_sdk.core.staking.data.delegation.RedelegationEntry]
validator_dst_address: ValAddress
validator_src_address: ValAddress
class terra_sdk.core.staking.data.delegation.RedelegationEntry(initial_balance, balance, shares_dst, creation_height, completion_time)[source]

Contains information about an active redelegated lot of Luna.

balance: int
completion_time: str
creation_height: int
initial_balance: int
shares_dst: terra_sdk.core.numeric.Dec
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

class terra_sdk.core.staking.data.delegation.UnbondingDelegation(delegator_address, validator_address, entries)[source]

Contains information about undelegations for a delegation pair (delegator_address, validator_address)

delegator_address: AccAddress
entries: List[terra_sdk.core.staking.data.delegation.UnbondingEntry]
validator_address: ValAddress
class terra_sdk.core.staking.data.delegation.UnbondingEntry(initial_balance, balance, creation_height, completion_time)[source]

Contains information about an active unbonding lot of Luna.

balance: int
completion_time: str
creation_height: int
initial_balance: int
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

Validator

class terra_sdk.core.staking.data.validator.Commission(commission_rates, update_time)[source]

Contains information about validator’s commission rates.

commission_rates: terra_sdk.core.staking.data.validator.CommissionRates

Validator commission rates.

update_time: str

Last time commission rates were updated.

class terra_sdk.core.staking.data.validator.CommissionRates(rate, max_rate, max_change_rate)[source]

Data structure for validator’s commission rates & policy.

max_change_rate: terra_sdk.core.numeric.Dec

Maximum % change of commission per day.

max_rate: terra_sdk.core.numeric.Dec

Maximum % commission rate permitted by policy.

rate: terra_sdk.core.numeric.Dec

Current % commission rate.

class terra_sdk.core.staking.data.validator.Description(moniker='', identity='', website='', details='', security_contact='')[source]

Validator description entry.

Parameters
  • moniker (str) – validator name, aka: “Terran One”

  • identity (str) – keybase.io identifier (used for setting logo)

  • website (str) – validator website

  • details (str) – longer description of validator

  • security_contact (str) – contact information for validator

DO_NOT_MODIFY = '[do-not-modify]'
class terra_sdk.core.staking.data.validator.Validator(operator_address, consensus_pubkey, jailed, status, tokens, delegator_shares, description, unbonding_height, unbonding_time, commission, min_self_delegation)[source]

Contains information about a registered validator.

commission: terra_sdk.core.staking.data.validator.Commission
consensus_pubkey: ValConsPubKey
delegator_shares: terra_sdk.core.numeric.Dec
description: terra_sdk.core.staking.data.validator.Description
jailed: bool
min_self_delegation: int
operator_address: ValAddress
status: int
to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

tokens: int
unbonding_height: int
unbonding_time: str

Messages

Staking module message types.

class terra_sdk.core.staking.msgs.MsgBeginRedelegate(delegator_address, validator_src_address, validator_dst_address, amount)[source]

Redelegate staked Luna from validator_src_address to valdiator_dst_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_src_address (ValAddress) – validator to remove delegation FROM

  • validator_dst_address (ValAddress) – validator to transfer delegate TO

  • amount (Union[str, dict, Coin]) – coin (LUNA) to redelegate

action = 'begin_redelegate'
type: str = 'staking/MsgBeginRedelegate'
class terra_sdk.core.staking.msgs.MsgCreateValidator(description, commission, min_self_delegation, delegator_address, validator_address, pubkey, value)[source]

Register a new validator with the Terra protocol.

Parameters
  • description (Description) – validator description

  • commission (CommissionRates) – validator commission rates

  • min_self_delegation (int) – minimum self-delegation policy

  • delegator_address (AccAddress) – validator’s account address

  • validator_address (ValAddress) – validator’s operator address

  • pubkey (ValConsPubKey) – validator consensus (Tendermint) public key

  • value (Coin.Input) – initial amount of Luna toi self-delegate

action = 'create_validator'
type: str = 'staking/MsgCreateValidator'
class terra_sdk.core.staking.msgs.MsgDelegate(delegator_address, validator_address, amount)[source]

Delegate Luna to validator at validator_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_address (ValAddress) – validator to delegate to

  • amount (Union[str, dict, Coin]) – coin (LUNA) to delegate

action = 'delegate'
type: str = 'staking/MsgDelegate'
class terra_sdk.core.staking.msgs.MsgEditValidator(Description, address, commission_rate=None, min_self_delegation=None)[source]

Revise validator description and configuration.

Parameters
  • Description (Description) – updated validator description

  • address (ValAddress) – validator operator address

  • commission_rates – new validator commission rate,

  • min_self_delegation (Optional[int]) – new minimum self delegation,

action = 'edit_validator'
type: str = 'staking/MsgEditValidator'
class terra_sdk.core.staking.msgs.MsgUndelegate(delegator_address, validator_address, amount)[source]

Undelegate Luna from staking position with validator_address.

Parameters
  • delegator_address (AccAddress) – delegator

  • validator_address (ValAddress) – validator to undelegate from

  • amount (Union[str, dict, Coin]) – coin (LUNA) to undelegate

action = 'begin_unbonding'
type: str = 'staking/MsgUndelegate'