TokenInstruction.initializeAccount2 constructor
TokenInstruction.initializeAccount2({
- required Ed25519HDPublicKey pubKey,
- required Ed25519HDPublicKey mint,
- required Ed25519HDPublicKey owner,
Like TokenInstruction.initializeAccount, but the owner pubkey is passed
via instruction data rather than the accounts list. This variant may be
preferable when using Cross Program Invocation from an instruction that
does not need the owner's AccountInfo otherwise.
Implementation
factory TokenInstruction.initializeAccount2({
required Ed25519HDPublicKey pubKey,
required Ed25519HDPublicKey mint,
required Ed25519HDPublicKey owner,
}) =>
TokenInstruction._(
accounts: [
AccountMeta.writeable(pubKey: pubKey, isSigner: true),
AccountMeta.readonly(pubKey: mint, isSigner: false),
AccountMeta.readonly(
pubKey: Ed25519HDPublicKey.fromBase58(Sysvar.rent),
isSigner: false,
),
],
data: ByteArray.merge([
TokenProgram.initializeAccount2InstructionIndex,
owner.toByteArray(),
]),
);