staking

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 24 Imported by: 11

README

Staking Precompile

The Staking precompile provides an EVM interface to the Cosmos SDK staking module. This enables smart contracts to perform staking operations including validator management, delegation, undelegation, redelegation.

Address

The precompile is available at the fixed address: 0x0000000000000000000000000000000000000800

Interface

Data Structures
// Validator description
struct Description {
    string moniker;
    string identity;
    string website;
    string securityContact;
    string details;
}

// Commission rates for validators
struct CommissionRates {
    uint256 rate;           // Current commission rate (as integer, e.g., 100 = 0.01 = 1%)
    uint256 maxRate;        // Maximum commission rate
    uint256 maxChangeRate;  // Maximum daily increase
}

// Validator information
struct Validator {
    string operatorAddress;     // Validator operator address (bech32)
    string consensusPubkey;     // Consensus public key
    bool jailed;                // Whether validator is jailed
    BondStatus status;          // Bonding status
    uint256 tokens;             // Total tokens
    uint256 delegatorShares;    // Total delegator shares
    Description description;    // Description struct
    int64 unbondingHeight;      // Height when unbonding started
    int64 unbondingTime;        // Time when unbonding completes
    uint256 commission;         // Current commission rate
    uint256 minSelfDelegation;  // Minimum self delegation
}

// Validator bonding status
enum BondStatus {
    Unspecified,
    Unbonded,
    Unbonding,
    Bonded
}

// Unbonding delegation entry
struct UnbondingDelegationEntry {
    int64 creationHeight;
    int64 completionTime;
    uint256 initialBalance;
    uint256 balance;
    uint64 unbondingId;
    int64 unbondingOnHoldRefCount;
}
Transaction Methods
// Create a new validator
function createValidator(
    Description calldata description,
    CommissionRates calldata commissionRates,
    uint256 minSelfDelegation,
    address validatorAddress,
    string memory pubkey,
    uint256 value
) external returns (bool success);

// Edit validator parameters
function editValidator(
    Description calldata description,
    address validatorAddress,
    int256 commissionRate,      // Use -1 to keep current value
    int256 minSelfDelegation    // Use -1 to keep current value
) external returns (bool success);

// Delegate tokens to a validator
function delegate(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount
) external returns (bool success);

// Undelegate tokens from a validator
function undelegate(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount
) external returns (int64 completionTime);

// Redelegate tokens between validators
function redelegate(
    address delegatorAddress,
    string memory validatorSrcAddress,
    string memory validatorDstAddress,
    uint256 amount
) external returns (int64 completionTime);

// Cancel an unbonding delegation
function cancelUnbondingDelegation(
    address delegatorAddress,
    string memory validatorAddress,
    uint256 amount,
    uint256 creationHeight
) external returns (bool success);
Query Methods
// Query delegation info
function delegation(
    address delegatorAddress,
    string memory validatorAddress
) external view returns (uint256 shares, Coin calldata balance);

// Query unbonding delegation
function unbondingDelegation(
    address delegatorAddress,
    string memory validatorAddress
) external view returns (UnbondingDelegationOutput calldata unbondingDelegation);

// Query validator info
function validator(
    address validatorAddress
) external view returns (Validator calldata validator);

// Query validators by status
function validators(
    string memory status,
    PageRequest calldata pageRequest
) external view returns (
    Validator[] calldata validators,
    PageResponse calldata pageResponse
);

// Query redelegation info
function redelegation(
    address delegatorAddress,
    string memory srcValidatorAddress,
    string memory dstValidatorAddress
) external view returns (RedelegationOutput calldata redelegation);

Gas Costs

Gas costs are calculated dynamically based on:

  • Base gas for the method
  • Complexity of the staking operation
  • Storage operations for state changes

The precompile uses standard gas configuration for storage operations.

Implementation Details

Validator Creation
  1. Self-delegation: Initial stake must meet minimum self-delegation requirement
  2. Commission rates: Must be within valid ranges (0-100%)
  3. Public key: Must be a valid ed25519 consensus public key
  4. Description: All fields are optional except moniker
Delegation Operations
  • Delegate: Stakes tokens with a validator, receiving shares in return
  • Undelegate: Initiates unbonding process (subject to unbonding period)
  • Redelegate: Moves stake between validators without unbonding period
  • Cancel Unbonding: Reverses an unbonding delegation before completion
Address Formats
  • Validator addresses: Can be either Ethereum hex or Cosmos bech32 format
  • Delegator addresses: Ethereum hex addresses
  • Consensus pubkey: Base64 encoded ed25519 public key
Commission Updates
  • Validators can update commission rates within constraints
  • Cannot exceed maxRate or increase by more than maxChangeRate per day
  • Use special constant -1 to keep current values unchanged

Events

event CreateValidator(
    address indexed validatorAddress,
    uint256 value
);

event EditValidator(
    address indexed validatorAddress,
    int256 commissionRate,
    int256 minSelfDelegation
);

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

event Unbond(
    address indexed delegatorAddress,
    string indexed validatorAddress,
    uint256 amount,
    int64 completionTime
);

event Redelegate(
    address indexed delegatorAddress,
    string indexed validatorSrcAddress,
    string indexed validatorDstAddress,
    uint256 amount,
    int64 completionTime
);

event CancelUnbondingDelegation(
    address indexed delegatorAddress,
    string indexed validatorAddress,
    uint256 amount,
    uint256 creationHeight
);

Security Considerations

  1. Sender Verification: All operations verify the transaction sender matches the specified address
  2. Balance Handling: Uses the balance handler for proper native token management
  3. Unbonding Period: Enforces chain-wide unbonding period for security
  4. Slashing Risk: Delegated tokens are subject to slashing for validator misbehavior

Usage Examples

Creating a Validator
StakingI staking = StakingI(STAKING_PRECOMPILE_ADDRESS);

Description memory desc = Description({
    moniker: "My Validator",
    identity: "keybase-identity",
    website: "https://validator.example.com",
    securityContact: "security@example.com",
    details: "Professional validator service"
});

CommissionRates memory rates = CommissionRates({
    rate: 100,           // 1% (100 / 10000)
    maxRate: 2000,       // 20% max
    maxChangeRate: 100   // 1% max daily change
});

// Create validator with 1000 tokens self-delegation
bool success = staking.createValidator(
    desc,
    rates,
    1000e18,             // Min self delegation
    msg.sender,          // Validator address
    "validator_pubkey",  // Consensus public key
    1000e18              // Initial self delegation
);
Delegating to a Validator
StakingI staking = StakingI(STAKING_PRECOMPILE_ADDRESS);

// Delegate 100 tokens to a validator
string memory validatorAddr = "evmosvaloper1..."; // Bech32 validator address
bool success = staking.delegate(msg.sender, validatorAddr, 100e18);

// Query delegation
(uint256 shares, Coin memory balance) = staking.delegation(msg.sender, validatorAddr);
Managing Delegations
// Undelegate 50 tokens (starts unbonding period)
int64 completionTime = staking.undelegate(msg.sender, validatorAddr, 50e18);

// Redelegate to another validator (no unbonding period)
string memory newValidator = "evmosvaloper2...";
int64 redelegationTime = staking.redelegate(
    msg.sender,
    validatorAddr,
    newValidator,
    25e18
);

// Cancel unbonding (must specify the creation height)
uint256 creationHeight = 12345;
staking.cancelUnbondingDelegation(
    msg.sender,
    validatorAddr,
    50e18,
    creationHeight
);

Integration Notes

  • The precompile integrates directly with the Cosmos SDK staking module
  • All staking parameters and rules from the chain apply
  • Amounts use the bond denomination precision (typically 18 decimals)
  • Validator addresses can be provided in either hex or bech32 format
  • Commission rates are integers where 10000 = 100%

Documentation

Index

Constants

View Source
const (
	// ErrNoDelegationFound is raised when no delegation is found for the given delegator and validator addresses.
	ErrNoDelegationFound = "delegation with delegator %s not found for validator %s"
	// ErrDifferentOriginFromValidator is raised when the origin address is not the same as the validator address.
	ErrDifferentOriginFromValidator = "origin address %s is not the same as validator operator address %s"
	// ErrCannotCallFromContract is raised when a function cannot be called from a smart contract.
	ErrCannotCallFromContract = "this method can only be called directly to the precompile, not from a smart contract"
)
View Source
const (
	// EventTypeCreateValidator defines the event type for the staking CreateValidator transaction.
	EventTypeCreateValidator = "CreateValidator"
	// EventTypeEditValidator defines the event type for the staking EditValidator transaction.
	EventTypeEditValidator = "EditValidator"
	// EventTypeDelegate defines the event type for the staking Delegate transaction.
	EventTypeDelegate = "Delegate"
	// EventTypeUnbond defines the event type for the staking Undelegate transaction.
	EventTypeUnbond = "Unbond"
	// EventTypeRedelegate defines the event type for the staking Redelegate transaction.
	EventTypeRedelegate = "Redelegate"
	// EventTypeCancelUnbondingDelegation defines the event type for the staking CancelUnbondingDelegation transaction.
	EventTypeCancelUnbondingDelegation = "CancelUnbondingDelegation"
)
View Source
const (
	// DelegationMethod defines the ABI method name for the staking Delegation
	// query.
	DelegationMethod = "delegation"
	// UnbondingDelegationMethod defines the ABI method name for the staking
	// UnbondingDelegationMethod query.
	UnbondingDelegationMethod = "unbondingDelegation"
	// ValidatorMethod defines the ABI method name for the staking
	// Validator query.
	ValidatorMethod = "validator"
	// ValidatorsMethod defines the ABI method name for the staking
	// Validators query.
	ValidatorsMethod = "validators"
	// RedelegationMethod defines the ABI method name for the staking
	// Redelegation query.
	RedelegationMethod = "redelegation"
	// RedelegationsMethod defines the ABI method name for the staking
	// Redelegations query.
	RedelegationsMethod = "redelegations"
)
View Source
const (
	// CreateValidatorMethod defines the ABI method name for the staking create validator transaction
	CreateValidatorMethod = "createValidator"
	// EditValidatorMethod defines the ABI method name for the staking edit validator transaction
	EditValidatorMethod = "editValidator"
	// DelegateMethod defines the ABI method name for the staking Delegate
	// transaction.
	DelegateMethod = "delegate"
	// UndelegateMethod defines the ABI method name for the staking Undelegate
	// transaction.
	UndelegateMethod = "undelegate"
	// RedelegateMethod defines the ABI method name for the staking Redelegate
	// transaction.
	RedelegateMethod = "redelegate"
	// CancelUnbondingDelegationMethod defines the ABI method name for the staking
	// CancelUnbondingDelegation transaction.
	CancelUnbondingDelegationMethod = "cancelUnbondingDelegation"
)
View Source
const (
	// DoNotModifyCommissionRate constant used in flags to indicate that commission rate field should not be updated
	DoNotModifyCommissionRate = -1
	// DoNotModifyMinSelfDelegation constant used in flags to indicate that min self delegation field should not be updated
	DoNotModifyMinSelfDelegation = -1
)

Variables

View Source
var (
	ABI abi.ABI
)

Functions

func FormatConsensusPubkey

func FormatConsensusPubkey(consensusPubkey *codectypes.Any) string

FormatConsensusPubkey format ConsensusPubkey into a base64 string

func NewDelegationRequest

func NewDelegationRequest(args []interface{}, addrCdc address.Codec) (*stakingtypes.QueryDelegationRequest, error)

NewDelegationRequest creates a new QueryDelegationRequest instance and does sanity checks on the given arguments before populating the request.

func NewMsgCancelUnbondingDelegation

func NewMsgCancelUnbondingDelegation(args []interface{}, denom string, addrCdc address.Codec) (*stakingtypes.MsgCancelUnbondingDelegation, common.Address, error)

NewMsgCancelUnbondingDelegation creates a new MsgCancelUnbondingDelegation instance and does sanity checks on the given arguments before populating the message.

func NewMsgCreateValidator

func NewMsgCreateValidator(args []interface{}, denom string, addrCdc address.Codec) (*stakingtypes.MsgCreateValidator, common.Address, error)

NewMsgCreateValidator creates a new MsgCreateValidator instance and does sanity checks on the given arguments before populating the message.

func NewMsgDelegate

func NewMsgDelegate(args []interface{}, denom string, addrCdc address.Codec) (*stakingtypes.MsgDelegate, common.Address, error)

NewMsgDelegate creates a new MsgDelegate instance and does sanity checks on the given arguments before populating the message.

func NewMsgEditValidator

func NewMsgEditValidator(args []interface{}) (*stakingtypes.MsgEditValidator, common.Address, error)

NewMsgEditValidator creates a new MsgEditValidator instance and does sanity checks on the given arguments before populating the message.

func NewMsgRedelegate

func NewMsgRedelegate(args []interface{}, denom string, addrCdc address.Codec) (*stakingtypes.MsgBeginRedelegate, common.Address, error)

NewMsgRedelegate creates a new MsgRedelegate instance and does sanity checks on the given arguments before populating the message.

func NewMsgUndelegate

func NewMsgUndelegate(args []interface{}, denom string, addrCdc address.Codec) (*stakingtypes.MsgUndelegate, common.Address, error)

NewMsgUndelegate creates a new MsgUndelegate instance and does sanity checks on the given arguments before populating the message.

func NewRedelegationsRequest

func NewRedelegationsRequest(method *abi.Method, args []interface{}, addrCdc address.Codec) (*stakingtypes.QueryRedelegationsRequest, error)

NewRedelegationsRequest create a new QueryRedelegationsRequest instance and does sanity checks on the given arguments before populating the request.

func NewUnbondingDelegationRequest

func NewUnbondingDelegationRequest(args []interface{}, addrCdc address.Codec) (*stakingtypes.QueryUnbondingDelegationRequest, error)

NewUnbondingDelegationRequest creates a new QueryUnbondingDelegationRequest instance and does sanity checks on the given arguments before populating the request.

func NewValidatorRequest

func NewValidatorRequest(args []interface{}) (*stakingtypes.QueryValidatorRequest, error)

NewValidatorRequest create a new QueryValidatorRequest instance and does sanity checks on the given arguments before populating the request.

func NewValidatorsRequest

func NewValidatorsRequest(method *abi.Method, args []interface{}) (*stakingtypes.QueryValidatorsRequest, error)

NewValidatorsRequest create a new QueryValidatorsRequest instance and does sanity checks on the given arguments before populating the request.

Types

type Commission

type Commission = struct {
	Rate          *big.Int "json:\"rate\""
	MaxRate       *big.Int "json:\"maxRate\""
	MaxChangeRate *big.Int "json:\"maxChangeRate\""
}

Commission use golang type alias defines a validator commission. since solidity does not support decimals, after passing in the big int, convert the big int into a decimal with a precision of 18

type DelegationOutput

type DelegationOutput struct {
	Shares  *big.Int
	Balance cmn.Coin
}

DelegationOutput is a struct to represent the key information from a delegation response.

func (*DelegationOutput) FromResponse

FromResponse populates the DelegationOutput from a QueryDelegationResponse.

func (*DelegationOutput) Pack

func (do *DelegationOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

type Description

type Description = struct {
	Moniker         string `json:"moniker"`
	Identity        string `json:"identity"`
	Website         string `json:"website"`
	SecurityContact string `json:"securityContact"`
	Details         string `json:"details"`
}

Description defines a validator description.

func NewDescriptionFromResponse added in v0.5.0

func NewDescriptionFromResponse(d stakingtypes.Description) Description

type EventCancelUnbonding

type EventCancelUnbonding struct {
	DelegatorAddress common.Address
	ValidatorAddress common.Address
	Amount           *big.Int
	CreationHeight   *big.Int
}

EventCancelUnbonding defines the event data for the staking CancelUnbond transaction.

type EventCreateValidator

type EventCreateValidator struct {
	ValidatorAddress common.Address
	Value            *big.Int
}

EventCreateValidator defines the event data for the staking CreateValidator transaction.

type EventDelegate

type EventDelegate struct {
	DelegatorAddress common.Address
	ValidatorAddress common.Address
	Amount           *big.Int
	NewShares        *big.Int
}

EventDelegate defines the event data for the staking Delegate transaction.

type EventEditValidator

type EventEditValidator struct {
	ValidatorAddress  common.Address
	CommissionRate    *big.Int
	MinSelfDelegation *big.Int
}

EventEditValidator defines the event data for the staking EditValidator transaction.

type EventRedelegate

type EventRedelegate struct {
	DelegatorAddress    common.Address
	ValidatorSrcAddress common.Address
	ValidatorDstAddress common.Address
	Amount              *big.Int
	CompletionTime      *big.Int
}

EventRedelegate defines the event data for the staking Redelegate transaction.

type EventUnbond

type EventUnbond struct {
	DelegatorAddress common.Address
	ValidatorAddress common.Address
	Amount           *big.Int
	CompletionTime   *big.Int
}

EventUnbond defines the event data for the staking Undelegate transaction.

type Precompile

type Precompile struct {
	cmn.Precompile

	abi.ABI
	// contains filtered or unexported fields
}

Precompile defines the precompiled contract for staking.

func NewPrecompile

func NewPrecompile(
	stakingKeeper cmn.StakingKeeper,
	stakingMsgServer stakingtypes.MsgServer,
	stakingQuerier stakingtypes.QueryServer,
	bankKeeper cmn.BankKeeper,
	addrCdc address.Codec,
) *Precompile

NewPrecompile creates a new staking Precompile instance as a PrecompiledContract interface.

func (Precompile) CancelUnbondingDelegation

func (p Precompile) CancelUnbondingDelegation(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

CancelUnbondingDelegation will cancel the unbonding of a delegation and delegate back to the validator being unbonded from. The provided amount cannot be negative. This is validated in the msg.ValidateBasic() function.

func (Precompile) CreateValidator

func (p Precompile) CreateValidator(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

CreateValidator performs create validator.

func (*Precompile) Delegate

func (p *Precompile) Delegate(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Delegate performs a delegation of coins from a delegator to a validator.

func (Precompile) Delegation

func (p Precompile) Delegation(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Delegation returns the delegation that a delegator has with a specific validator.

func (Precompile) EditValidator

func (p Precompile) EditValidator(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

EditValidator performs edit validator.

func (Precompile) EmitCancelUnbondingDelegationEvent

func (p Precompile) EmitCancelUnbondingDelegationEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgCancelUnbondingDelegation, delegatorAddr common.Address) error

EmitCancelUnbondingDelegationEvent creates a new cancel unbonding delegation event emitted on a CancelUnbondingDelegation transaction.

func (Precompile) EmitCreateValidatorEvent

func (p Precompile) EmitCreateValidatorEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgCreateValidator, validatorAddr common.Address) error

EmitCreateValidatorEvent creates a new create validator event emitted on a CreateValidator transaction.

func (Precompile) EmitDelegateEvent

func (p Precompile) EmitDelegateEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgDelegate, delegatorAddr common.Address) error

EmitDelegateEvent creates a new delegate event emitted on a Delegate transaction.

func (Precompile) EmitEditValidatorEvent

func (p Precompile) EmitEditValidatorEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgEditValidator, validatorAddr common.Address) error

EmitEditValidatorEvent creates a new edit validator event emitted on a EditValidator transaction.

func (Precompile) EmitRedelegateEvent

func (p Precompile) EmitRedelegateEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgBeginRedelegate, delegatorAddr common.Address, completionTime int64) error

EmitRedelegateEvent creates a new redelegate event emitted on a Redelegate transaction.

func (Precompile) EmitUnbondEvent

func (p Precompile) EmitUnbondEvent(ctx sdk.Context, stateDB vm.StateDB, msg *stakingtypes.MsgUndelegate, delegatorAddr common.Address, completionTime int64) error

EmitUnbondEvent creates a new unbond event emitted on an Undelegate transaction.

func (Precompile) Execute added in v0.5.0

func (p Precompile) Execute(ctx sdk.Context, stateDB vm.StateDB, contract *vm.Contract, readOnly bool) ([]byte, error)

func (Precompile) IsTransaction

func (Precompile) IsTransaction(method *abi.Method) bool

IsTransaction checks if the given method name corresponds to a transaction or query.

Available staking transactions are:

  • CreateValidator
  • EditValidator
  • Delegate
  • Undelegate
  • Redelegate
  • CancelUnbondingDelegation

func (Precompile) Logger

func (p Precompile) Logger(ctx sdk.Context) log.Logger

Logger returns a precompile-specific logger.

func (Precompile) Redelegate

func (p Precompile) Redelegate(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Redelegate performs a redelegation of coins for a delegate from a source validator to a destination validator. The provided amount cannot be negative. This is validated in the msg.ValidateBasic() function.

func (Precompile) Redelegation

func (p Precompile) Redelegation(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

Redelegation returns the redelegation between two validators for a delegator.

func (Precompile) Redelegations

func (p Precompile) Redelegations(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

Redelegations returns the redelegations according to the specified criteria (delegator address and/or validator source address and/or validator destination address or all existing redelegations) with pagination. Pagination is only supported for querying redelegations from a source validator or to query all redelegations.

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas returns the required bare minimum gas to execute the precompile.

func (Precompile) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)

func (Precompile) UnbondingDelegation

func (p Precompile) UnbondingDelegation(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

UnbondingDelegation returns the delegation currently being unbonded for a delegator from a specific validator.

func (Precompile) Undelegate

func (p Precompile) Undelegate(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

Undelegate performs the undelegation of coins from a validator for a delegate. The provided amount cannot be negative. This is validated in the msg.ValidateBasic() function.

func (Precompile) Validator

func (p Precompile) Validator(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

Validator returns the validator information for a given validator address.

func (Precompile) Validators

func (p Precompile) Validators(
	ctx sdk.Context,
	method *abi.Method,
	_ *vm.Contract,
	args []interface{},
) ([]byte, error)

Validators returns the validators information with a provided status & pagination (optional).

type Redelegation

type Redelegation struct {
	DelegatorAddress    string
	ValidatorSrcAddress string
	ValidatorDstAddress string
	Entries             []RedelegationEntry
}

Redelegation contains the list of a particular delegator's redelegating bonds from a particular source validator to a particular destination validator.

type RedelegationEntry

type RedelegationEntry struct {
	CreationHeight int64
	CompletionTime int64
	InitialBalance *big.Int
	SharesDst      *big.Int
}

RedelegationEntry is a struct to represent the key information from a redelegation entry response.

type RedelegationEntryResponse

type RedelegationEntryResponse struct {
	RedelegationEntry RedelegationEntry
	Balance           *big.Int
}

RedelegationEntryResponse is equivalent to a RedelegationEntry except that it contains a balance in addition to shares which is more suitable for client responses.

type RedelegationOutput

type RedelegationOutput struct {
	Redelegation RedelegationValues
}

RedelegationOutput returns the output for a redelegation query.

func (*RedelegationOutput) FromResponse

FromResponse populates the RedelegationOutput from a QueryRedelegationsResponse.

type RedelegationRequest

type RedelegationRequest struct {
	DelegatorAddress    sdk.AccAddress
	ValidatorSrcAddress sdk.ValAddress
	ValidatorDstAddress sdk.ValAddress
}

RedelegationRequest is a struct that contains the information to pass into a redelegation query.

func NewRedelegationRequest

func NewRedelegationRequest(args []interface{}) (*RedelegationRequest, error)

NewRedelegationRequest create a new QueryRedelegationRequest instance and does sanity checks on the given arguments before populating the request.

type RedelegationResponse

type RedelegationResponse struct {
	Redelegation Redelegation
	Entries      []RedelegationEntryResponse
}

RedelegationResponse is equivalent to a Redelegation except that its entries contain a balance in addition to shares which is more suitable for client responses.

type RedelegationValues

type RedelegationValues struct {
	DelegatorAddress    string
	ValidatorSrcAddress string
	ValidatorDstAddress string
	Entries             []RedelegationEntry
}

RedelegationValues is a struct to represent the key information from a redelegation response.

type RedelegationsInput

type RedelegationsInput struct {
	DelegatorAddress    common.Address
	SrcValidatorAddress string
	DstValidatorAddress string
	PageRequest         query.PageRequest
}

RedelegationsInput is a struct to represent the input information for the redelegations query. Needed to unpack arguments into the PageRequest struct.

type RedelegationsOutput

type RedelegationsOutput struct {
	Response     []RedelegationResponse
	PageResponse query.PageResponse
}

RedelegationsOutput is a struct to represent the key information from a redelegations response.

func (*RedelegationsOutput) FromResponse

FromResponse populates the RedelgationsOutput from a QueryRedelegationsResponse.

func (*RedelegationsOutput) Pack

func (ro *RedelegationsOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

type RedelegationsRequest

type RedelegationsRequest struct {
	DelegatorAddress sdk.AccAddress
	MaxRetrieve      int64
}

RedelegationsRequest is a struct that contains the information to pass into a redelegations query.

type UnbondingDelegationEntry

type UnbondingDelegationEntry struct {
	CreationHeight          int64
	CompletionTime          int64
	InitialBalance          *big.Int
	Balance                 *big.Int
	UnbondingId             uint64 //nolint
	UnbondingOnHoldRefCount int64
}

UnbondingDelegationEntry is a struct that contains the information about an unbonding delegation entry.

type UnbondingDelegationOutput

type UnbondingDelegationOutput struct {
	UnbondingDelegation UnbondingDelegationResponse
}

UnbondingDelegationOutput is the output response returned by the query method.

func (*UnbondingDelegationOutput) FromResponse

FromResponse populates the DelegationOutput from a QueryDelegationResponse.

type UnbondingDelegationResponse

type UnbondingDelegationResponse struct {
	DelegatorAddress string
	ValidatorAddress string
	Entries          []UnbondingDelegationEntry
}

UnbondingDelegationResponse is a struct that contains the information about an unbonding delegation.

type ValidatorInfo

type ValidatorInfo struct {
	OperatorAddress   string      `abi:"operatorAddress"`
	ConsensusPubkey   string      `abi:"consensusPubkey"`
	Jailed            bool        `abi:"jailed"`
	Status            uint8       `abi:"status"`
	Tokens            *big.Int    `abi:"tokens"`
	DelegatorShares   *big.Int    `abi:"delegatorShares"` // TODO: Decimal
	Description       Description `abi:"description"`
	UnbondingHeight   int64       `abi:"unbondingHeight"`
	UnbondingTime     int64       `abi:"unbondingTime"`
	Commission        *big.Int    `abi:"commission"`
	MinSelfDelegation *big.Int    `abi:"minSelfDelegation"`
}

ValidatorInfo is a struct to represent the key information from a validator response.

func DefaultValidatorInfo added in v0.5.0

func DefaultValidatorInfo() ValidatorInfo

func NewValidatorInfoFromResponse added in v0.5.0

func NewValidatorInfoFromResponse(v stakingtypes.Validator) ValidatorInfo

type ValidatorOutput

type ValidatorOutput struct {
	Validator ValidatorInfo
}

type ValidatorsInput

type ValidatorsInput struct {
	Status      string
	PageRequest query.PageRequest
}

ValidatorsInput is a struct to represent the input information for the validators query. Needed to unpack arguments into the PageRequest struct.

type ValidatorsOutput

type ValidatorsOutput struct {
	Validators   []ValidatorInfo
	PageResponse query.PageResponse
}

ValidatorsOutput is a struct to represent the key information from a validators response.

func (*ValidatorsOutput) FromResponse

FromResponse populates the ValidatorsOutput from a QueryValidatorsResponse.

func (*ValidatorsOutput) Pack

func (vo *ValidatorsOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL