delegateStake static method
Delegate a stake to a particular vote account.
Keys:
[w]
stakeAccount
- Initialized stake account to be delegated.[]
voteAccount
- Vote account to which this stake will be delegated.[s]
authority
- Stake authority.
The entire balance of the staking account is staked. DelegateStake can be called multiple times, but re-delegation is delayed by one epoch.
Implementation
static TransactionInstruction delegateStake({
required final Pubkey stakeAccount,
required final Pubkey voteAccount,
required final Pubkey authority,
}) {
// 0. `[w]` Initialized stake account to be delegated
// 1. `[]` Vote account to which this stake will be delegated
// 2. `[]` Clock sysvar
// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history
// 4. `[]` Address of config account that carries stake config
// 5. `[s]` Stake authority
final List<AccountMeta> keys = [
AccountMeta.writable(stakeAccount),
AccountMeta(voteAccount),
AccountMeta(sysvarClockPubkey),
AccountMeta(sysvarStakeHistoryPubkey),
AccountMeta(StakeProgram.configId),
AccountMeta.signer(authority),
];
return _instance.createTransactionIntruction(
StakeInstruction.delegateStake,
keys: keys,
);
}