import {
MsgBeginRedelegate,
MsgBroadcasterWithPk,
} from "@injectivelabs/sdk-ts";
import { toChainFormat } from "@injectivelabs/utils";
import { Network } from "@injectivelabs/networks";
const denom = "inj";
const privateKey = "0x...";
const amount = toChainFormat(5);
const injectiveAddress = "inj1...";
const sourceValidatorAddress = "inj1...";
const destinationValidatorAddress = "inj1...";
const msg = MsgBeginRedelegate.fromJSON({
injectiveAddress,
dstValidatorAddress: destinationValidatorAddress,
srcValidatorAddress: sourceValidatorAddress,
amount: {
denom,
amount,
},
});
const txHash = await new MsgBroadcasterWithPk({
privateKey,
network: Network.Testnet,
}).broadcast({
msgs: msg,
});
console.log(txHash);