authorize static method
TransactionInstruction
authorize({
- required Pubkey stakeAccount,
- required Pubkey authority,
- Pubkey? custodian,
- required Pubkey newAuthority,
- required StakeAuthorize authorityType,
Authorize a key to manage stake or withdrawal.
Keys:
[w]
stakeAccount
- Stake account to be updated.[s]
authority
- The stake or withdraw authority.[s]
custodian
- Lockup authority, if updating StakeAuthorize.withdrawer before lockup.
Data:
newAuthority
authorityType
Implementation
static TransactionInstruction authorize({
// Keys
required final Pubkey stakeAccount,
required final Pubkey authority,
final Pubkey? custodian,
// Data
required final Pubkey newAuthority,
required final StakeAuthorize authorityType,
}) {
// 0. `[w]` Stake account to be updated
// 1. `[]` Clock sysvar
// 2. `[s]` The stake or withdraw authority
// 3. `[s]` Lockup authority, if updating StakeAuthorize.withdrawer before lockup.
final List<AccountMeta> keys = [
AccountMeta.writable(stakeAccount),
AccountMeta(sysvarClockPubkey),
AccountMeta.signer(authority),
if (custodian != null) AccountMeta.signer(custodian)
];
final List<Iterable<u8>> data = [
borsh.pubkey.encode(newAuthority.toBase58()),
borsh.enumeration(StakeAuthorize.values).encode(authorityType),
[0, 0, 0], // padding
];
return _instance.createTransactionIntruction(
StakeInstruction.authorize,
keys: keys,
data: data,
);
}