-
Notifications
You must be signed in to change notification settings - Fork 196
04CoreModulesDistribution
Ivan Angelkoski edited this page Jun 12, 2023
·
5 revisions
The distribution
module is extended from the cosmos sdk distribution module, where delegator can withdraw their staking rewards from the validator.
Distribution -> MsgWithdrawValidatorCommission
This message is used to withdraw all available delegator staking rewards from the validator.
import {
MsgBroadcasterWithPk,
MsgWithdrawDelegatorReward,
} from "@injectivelabs/sdk-ts";
import { ChainId } from "@injectivelabs/ts-types";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpointsForNetwork = getNetworkEndpoints(Network.Mainnet);
const injectiveAddress = "inj1...";
const validatorAddress = "inj1...";
/* create message in proto format */
const msg = MsgWithdrawDelegatorReward.fromJSON({
validatorAddress,
delegatorAddress: injectiveAddress,
});
const privateKey = "0x...";
/* broadcast transaction */
const txHash = await new MsgBroadcasterWithPk({
privateKey,
chainId: ChainId.Mainnet,
endpoints: endpointsForNetwork,
}).broadcast({
msgs: msg,
injectiveAddress,
});
console.log(txHash);
This message is used to by the validator to withdraw the commission earned.
import {
MsgBroadcasterWithPk,
MsgWithdrawValidatorCommission,
} from "@injectivelabs/sdk-ts";
import { ChainId } from "@injectivelabs/ts-types";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpointsForNetwork = getNetworkEndpoints(Network.Mainnet);
const injectiveAddress = "inj1...";
const validatorAddress = "inj1...";
/* create message in proto format */
const msg = MsgWithdrawValidatorCommission.fromJSON({
validatorAddress,
});
const privateKey = "0x...";
/* broadcast transaction */
const txHash = await new MsgBroadcasterWithPk({
privateKey,
chainId: ChainId.Mainnet,
endpoints: endpointsForNetwork,
}).broadcast({
msgs: msg,
injectiveAddress,
});
console.log(txHash);
Powering the future of decentralized finance.