redelegate static method
Redelegate activated stake to another vote account.
Upon success:
- the balance of the delegated stake account will be reduced to the undelegated amount in the account (rent exempt minimum and any additional lamports not part of the delegation), and scheduled for deactivation.
- the provided uninitialized stake account will receive the original balance of the delegated stake account, minus the rent exempt minimum, and scheduled for activation to the provided vote account. Any existing lamports in the uninitialized stake account will also be included in the re-delegation.
Keys:
[w]
delegatedStakeAccount
- Delegated stake account to be redelegated. The account must be fullyvactivated and carry a balance greater than or equal to the minimum delegation amountvplus rent exempt minimum.[w]
uninitializedtStakeAccount
- Uninitialized stake account that will hold the redelegated stake.[]
voteAccount
- Vote account to which this stake will be re-delegated.[s]
authority
- Stake authority.
Implementation
static TransactionInstruction redelegate({
required final Pubkey delegatedStakeAccount,
required final Pubkey uninitializedtStakeAccount,
required final Pubkey voteAccount,
required final Pubkey authority,
}) {
// 0. `[w]` Delegated stake account to be redelegated. The account must be fully activated and
// carry a balance greater than or equal to the minimum delegation amount plus rent exempt
// minimum
// 1. `[w]` Uninitialized stake account that will hold the redelegated stake
// 2. `[]` Vote account to which this stake will be re-delegated
// 3. `[]` Address of config account that carries stake config
// 4. `[s]` Stake authority
final List<AccountMeta> keys = [
AccountMeta.writable(delegatedStakeAccount),
AccountMeta.writable(uninitializedtStakeAccount),
AccountMeta(voteAccount),
AccountMeta(StakeProgram.configId),
AccountMeta.signer(authority),
];
return _instance.createTransactionIntruction(
StakeInstruction.redelegate,
keys: keys,
);
}