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