Redelegate Cosmos
The redelegate
namespace contains method used for sending transactions on delegation. The unique method to the redelegate
namespace is:
redelegate(token, address, amount, validatorSrcAddress)
: Redelegate user tokens.
Redelegate Code Example
ts
// Import SDK
import { Cosmos } from '@everstake/wallet-sdk';
// Token ID.
const token = process.env.TOKEN; // 3155f389-d943-4966-8e18-f159c2a6ef66
// Optional: You can get all user delegations.
// User wallet address.
const address = 'examplecosmos1hgmhc4hajlh8u47wmmls6ze4yrfekhs';
// Get all user delegations.
const getDelegations = await Cosmos.getDelegations(address);
// The amount that the user redelegates.
const amountRedelegate = getDelegations.result[0].balance.amount || 10;
// min value 0.01 (ATOM)
// Validator Address from Redelegation.
const validatorSrcAddress =
getDelegations.result[0].delegation.validator_address
|| 'cosmosvaloper1tflk30mq5vgqjdly92kkhhq3raev2hnz6eete3';
// Your source identificator
const sourceID = '99'
// redelegate - return transaction hash
const redelegate = await Cosmos.redelegate(
token,
address,
amountRedelegate,
validatorSrcAddress,
sourceID
);
console.log(redelegate); // { result: { address, msg, fee, memo } }