TokenInstruction.setAuthority constructor
TokenInstruction.setAuthority({
- required Ed25519HDPublicKey mintOrAccount,
- required Ed25519HDPublicKey currentAuthority,
- required AuthorityType authorityType,
- Ed25519HDPublicKey? newAuthority,
- List<
Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[],
Sets a new authority of a mint or account.
The newAuthority is optional and can be used to specify a new
authority for this token.
Implementation
factory TokenInstruction.setAuthority({
required Ed25519HDPublicKey mintOrAccount,
required Ed25519HDPublicKey currentAuthority,
required AuthorityType authorityType,
Ed25519HDPublicKey? newAuthority,
List<Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[],
}) =>
TokenInstruction._(
accounts: [
AccountMeta.writeable(pubKey: mintOrAccount, isSigner: false),
AccountMeta.readonly(
pubKey: currentAuthority,
isSigner: signers.isEmpty,
),
...signers.map(
(pubKey) => AccountMeta.readonly(pubKey: pubKey, isSigner: true),
),
],
data: ByteArray.merge([
TokenProgram.setAuthorityInstructionIndex,
ByteArray.u8(authorityType.value),
if (newAuthority != null) ...[
ByteArray.u8(1),
newAuthority.toByteArray(),
] else
ByteArray.u8(0),
]),
);