Staking

The provided Solidity code defines an interface StakingI that facilitates interaction between Solidity contracts and the staking functionalities in the Cosmos SDK.

Function

delegate

function delegate(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount
) external returns (bool success);
  • Purpose: This function is responsible for delegating coins from a delegator to a validator.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorAddress: Address of the validator to whom the delegation is made.

    • amount: Amount of the coin to be delegated to the validator.

    • Returns: A boolean indicating the success of the delegation.

undelegate

function undelegate(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount
) external returns (int64 completionTime);
  • Purpose: Performs an undelegation from a delegate and a validator.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorAddress: Address of the validator from whom the undelegation occurs.

    • amount: Amount to be undelegated from the validator.

    • Returns: The time (in int64 format) when the undelegation is completed.

redelegate

function redelegate(
    address delegatorAddress,
    string memory validatorSrcAddress,
    string memory validatorDstAddress,
    uint256 amount
) external returns (int64 completionTime);
  • Purpose: Executes a redelegation of coins from a delegator and a source validator to a destination validator.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorSrcAddress: Address of the validator from which the redelegation is initiated.

    • validatorDstAddress: Address of the validator to which the redelegation is destined. amount: Amount to be redelegated to the validator.

    • Returns: The time (in int64 format) when the redelegation is completed.

cancelUnbondingDelegation

function cancelUnbondingDelegation(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount,
    uint256 creationHeight
) external returns (bool success);
  • Purpose: Allows delegators to cancel an unbonding delegation entry and re-delegate back to a previous validator.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorAddress: Address of the validator.

    • amount: Amount of the coin.

    • creationHeight: The height at which the unbonding took place.

    • Returns: A boolean indicating the success of the cancellation of the unbonding delegation.

delegation

function delegation(
    address delegatorAddress,
    string memory validatorAddress
) external view returns (uint256 shares, Coin calldata balance);
  • Purpose: Queries the given amount of the bond denomination to a validator.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorAddress: Address of the validator.

    • Returns: The amount of shares that the delegator has received and the amount in Coin that the delegator has delegated to the given validator.

unbondingDelegation

function unbondingDelegation(
    address delegatorAddress,
    string memory validatorAddress
) external view returns (UnbondingDelegationEntry[] calldata entries);
  • Purpose: Returns the delegation shares and coins that are currently unbonding for a given delegator and validator pair.

  • Parameters:

    • delegatorAddress: Address of the delegator.

    • validatorAddress: Address of the validator.

    • Returns: An array of UnbondingDelegationEntry structs representing delegations that are currently unbonding.

Event

Delegate

 event Delegate(
        address indexed delegatorAddress,
        string indexed validatorAddress,
        uint256 amount,
        uint256 newShares
    );

Purpose: This event is emitted when a certain amount of tokens are delegated from a delegator address to a validator address. Parameters: delegatorAddress: The address of the delegator. validatorAddress: The address of the validator receiving the delegation. amount: The amount of Coin being delegated. newShares: The new delegation shares being held after the delegation. Usage: This event allows off-chain systems or applications to monitor and track the delegation activities occurring within the staking contract.

Unbond

  event Unbond(
        address indexed delegatorAddress,
        string indexed validatorAddress,
        uint256 amount,
        uint256 completionTime
    );
  • Purpose: Triggered when a certain amount of tokens are unbonded from the validator address to the delegator address.

  • Parameters:

    • delegatorAddress: The address of the delegator.

    • validatorAddress: The address of the validator.

    • amount: The amount of Coin being unbonded.

    • completionTime: The time at which the unbonding is completed.

    • Usage: This event serves to notify external systems about the completion of unbonding tokens from a validator.

Redelegate

event Redelegate(
        address indexed delegatorAddress,
        string indexed validatorSrcAddress,
        string indexed validatorDstAddress,
        uint256 amount,
        uint256 completionTime
    );
  • Purpose: Emits when a specific amount of tokens are redelegated from a source validator address to a destination validator address.

  • Parameters:

    • delegatorAddress: The address of the delegator.

    • validatorSrcAddress: The address of the source validator from which the delegation is retracted.

    • validatorDstAddress: The address of the destination validator to which the delegation is directed.

    • amount: The amount of Coin being redelegated.

    • completionTime: The time at which the redelegation is completed.

  • Usage: Allows off-chain systems to monitor the redelegation activities and track the movement of delegated tokens between validators.

CancelUnbondingDelegation

 event CancelUnbondingDelegation(
        address indexed delegatorAddress,
        string indexed validatorAddress,
        uint256 amount,
        uint256 creationHeight
    );
  • Purpose: Emitted when a certain amount of tokens that are in the process of unbonding from the validator address are bonded again.

  • Parameters:

    • delegatorAddress: The address of the delegator.

    • validatorAddress: The address of the validator.

    • amount: The amount of Coin that was in the unbonding process and is now canceled for rebonding.

    • creationHeight: The block height at which the unbonding of a delegation was initiated.

  • Usage: Provides a notification to external systems or interfaces about the cancellation of unbonding tokens, indicating a change in the delegation state.

Last updated