staking

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 17 Imported by: 0

README

Staking module

Usage

(Tx) Create validator
// Create validator using json file in the home directory
createValidatorMsg := types.CreateValidatorMsg{	
    ValidatorAddress: "xplavaloper10gv4zj9633v6cje6s2sc0a0xl52hjr6f9jp0q7",
    Website: "website",
    HomeDir: "/ABSPATH/.xpla",
    SecurityContact: "contact point",
    Identity: "identity",
    NodeID: "nodeid",
    ChainID: "chainid",
    Moniker: "moniker",
    Details: "details",
    Amount: "100000",
}

// Create validator using string values
createValidatorMsg := types.CreateValidatorMsg{
    NodeKey:                 NodeKey,
    PrivValidatorKey:        PrivValidatorKey,
    ValidatorAddress:        "xplavaloper10gv4zj9633v6cje6s2sc0a0xl52hjr6f9jp0q7",
    Moniker:                 "moniker",
    Identity:                "identity",
    Website:                 "website",
    SecurityContact:         "securityContact",
    Details:                 "details",
    Amount:                  "amount",
    CommissionRate:          "commissionRate",
    CommissionMaxRate:       "commissionMaxRate",
    CommissionMaxChangeRate: "commissionMaxChangeRate",
    MinSelfDelegation:       "minSelfDelegation",
}

txbytes, err := xplac.CreateValidator(createValidatorMsg).CreateAndSignTx()
(Tx) Edit validator
editValidatorMsg := types.EditValidatorMsg{		
    Website: "website",
    SecurityContact: "securitycontact",
    Identity: "identity",    
    Details: "details",
    Moniker: "moniker",
    CommissionRate: "commissionRate",	
    MinSelfDelegation: "minSelfDelegation",
}
txbytes, err := xplac.EditValidator(editValidatorMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Delegate
delegateMsg := types.DelegateMsg{
    Amount: "1000axpla",
    ValAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
txbytes, err := xplac.Delegate(delegateMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Unbond
unbondMsg := types.UnbondMsg{
    Amount: "100axpla",
    ValAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
txbytes, err := xplac.Unbond(unbondMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Redelegate
redelegateMsg := types.RedelegateMsg{
    Amount: "100axpla",
    ValSrcAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
    ValDstAddr: "xplavaloper1r7tdqs8zgtkty2u06yp5nw6dc6c9hvz9ak98r5",
}
txbytes, err := xplac.Redelegate(redelegateMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) validators
// Query all validators
res, err := xplac.QueryValidators().Query()

// Query validator by retrieving validator address
queryValidatorMsg := types.QueryValidatorMsg {
    ValidatorAddr: "xplavaloper13trl452wgle9qxpxhse9605k9x0399cm85pf34",
}
res, err := xplac.QueryValidators(queryValidatorMsg).Query()
(Query) delegation
// Query a delegation based on address and validator address 
queryDelegationMsg := types.QueryDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

// Query all delegations made by one delegator 
queryDelegationMsg := types.QueryDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}

// Query all delegations made to one validator
queryDelegationMsg := types.QueryDelegationMsg {
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryDelegation(queryDelegationMsg).Query()
(Query) unbonding delegation
// Query an unbonding-delegation record based on delegator and validator address
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

// Query all unbonding-delegations records for one delegator
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}

// Query all unbonding delegatations from a validator
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {    
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryUnbondingDelegation(queryUnbondingDelegationMsg).Query()
(Query) Redelegations
// Query a redelegation record based on delegator and a source and destination validator
queryRedelegationMsg := types.QueryRedelegationMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",    	
    SrcValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
    DstValidatorAddr: "xplavaloper1r7tdqs8zgtkty2u06yp5nw6dc6c9hvz9ak98r5",
}

// Query all redelegations records for one delegator
queryRedelegationMsg := types.QueryRedelegationMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",    		
}

// Query all outgoing redelegations from a validator
queryRedelegationMsg := types.QueryRedelegationMsg{
    SrcValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryRedelegation(queryRedelegationMsg).Query()
(Query) Historical info
historicalInfoMsg := types.HistoricalInfoMsg{
    Height: "2000",
}

res, err := xplac.HistoricalInfo(historicalInfoMsg).Query()
(Query) staking pool
res, err := xplac.StakingPool().Query()
(Query) staking params
res, err := xplac.StakingParams().Query()

Documentation

Index

Constants

View Source
const (
	StakingModule                               = "staking"
	StakingCreateValidatorMsgType               = "create-validator"
	StakingEditValidatorMsgType                 = "edit-validator"
	StakingDelegateMsgType                      = "delegate"
	StakingRedelegateMsgType                    = "redelegate"
	StakingUnbondMsgType                        = "unbond"
	StakingQueryValidatorMsgType                = "query-validator"
	StakingQueryValidatorsMsgType               = "query-validators"
	StakingQueryDelegationMsgType               = "query-delegation"
	StakingQueryDelegationsMsgType              = "query-delegations"
	StakingQueryDelegationsToMsgType            = "query-delegations-to"
	StakingQueryUnbondingDelegationMsgType      = "query-unbonding-delegation"
	StakingQueryUnbondingDelegationsMsgType     = "query-unbonding-delegations"
	StakingQueryUnbondingDelegationsFromMsgType = "query-unbonding-delegations-from"
	StakingQueryRedelegationMsgType             = "query-redelegation"
	StakingQueryRedelegationsMsgType            = "query-redelegations"
	StakingQueryRedelegationsFromMsgType        = "query-redelegations-from"
	StakingHistoricalInfoMsgType                = "historical-info"
	StakingQueryStakingPoolMsgType              = "query-staking-pool"
	StakingQueryStakingParamsMsgType            = "query-staking-params"
)

Variables

This section is empty.

Functions

func MakeCreateValidatorMsg

func MakeCreateValidatorMsg(createValidatorMsg types.CreateValidatorMsg, privKey key.PrivateKey, output string) (sdk.Msg, error)

(Tx) make msg - create validator

func MakeDelegateMsg

func MakeDelegateMsg(delegateMsg types.DelegateMsg, privKey key.PrivateKey) (stakingtypes.MsgDelegate, error)

(Tx) make msg - delegate

func MakeEditValidatorMsg

func MakeEditValidatorMsg(editValidatorMsg types.EditValidatorMsg, privKey key.PrivateKey) (stakingtypes.MsgEditValidator, error)

(Tx) make msg - edit validator

func MakeHistoricalInfoMsg

func MakeHistoricalInfoMsg(historicalInfoMsg types.HistoricalInfoMsg) (stakingtypes.QueryHistoricalInfoRequest, error)

(Query) make msg - historical

func MakeQueryDelegationMsg

func MakeQueryDelegationMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryDelegationRequest, error)

(Query) make msg - query delegation

func MakeQueryDelegationsMsg

func MakeQueryDelegationsMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryDelegatorDelegationsRequest, error)

(Query) make msg - query delegations

func MakeQueryDelegationsToMsg

func MakeQueryDelegationsToMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryValidatorDelegationsRequest, error)

(Query) make msg - query delegations to

func MakeQueryRedelegationMsg

func MakeQueryRedelegationMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegation

func MakeQueryRedelegationsFromMsg

func MakeQueryRedelegationsFromMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegations from

func MakeQueryRedelegationsMsg

func MakeQueryRedelegationsMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegations

func MakeQueryStakingParamsMsg

func MakeQueryStakingParamsMsg() (stakingtypes.QueryParamsRequest, error)

(Query) make msg - staking params

func MakeQueryStakingPoolMsg

func MakeQueryStakingPoolMsg() (stakingtypes.QueryPoolRequest, error)

(Query) make msg - staking pool

func MakeQueryUnbondingDelegationMsg

func MakeQueryUnbondingDelegationMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryUnbondingDelegationRequest, error)

(Query) make msg - query unbonding delegation

func MakeQueryUnbondingDelegationsFromMsg

func MakeQueryUnbondingDelegationsFromMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryValidatorUnbondingDelegationsRequest, error)

(Query) make msg - query unbonding delegations from

func MakeQueryUnbondingDelegationsMsg

func MakeQueryUnbondingDelegationsMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryDelegatorUnbondingDelegationsRequest, error)

(Query) make msg - query unbonding delegations

func MakeQueryValidatorMsg

func MakeQueryValidatorMsg(queryValidatorMsg types.QueryValidatorMsg) (stakingtypes.QueryValidatorRequest, error)

(Query) make msg - validator

func MakeQueryValidatorsMsg

func MakeQueryValidatorsMsg() (stakingtypes.QueryValidatorsRequest, error)

(Query) make msg - validators

func MakeRedelegateMsg

func MakeRedelegateMsg(redelegateMsg types.RedelegateMsg, privKey key.PrivateKey) (stakingtypes.MsgBeginRedelegate, error)

(Tx) make msg - redelegate

func MakeUnbondMsg

func MakeUnbondMsg(unbondMsg types.UnbondMsg, privKey key.PrivateKey) (stakingtypes.MsgUndelegate, error)

(Tx) make msg - unbond

Types

type FilePVKey

type FilePVKey struct {
	Address tmtypes.Address `json:"address"`
	PubKey  crypto.PubKey   `json:"pub_key"`
	PrivKey crypto.PrivKey  `json:"priv_key"`
}

type NodeKey

type NodeKey struct {
	PrivKey crypto.PrivKey `json:"priv_key"` // our priv key
}

Jump to

Keyboard shortcuts

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