TokenInstruction.mintTo constructor

TokenInstruction.mintTo({
  1. required int amount,
  2. required Ed25519HDPublicKey mint,
  3. required Ed25519HDPublicKey destination,
  4. required Ed25519HDPublicKey authority,
})

Mint the destination account with amount tokens of the mint token. The authority is the mint authority of the token.

The destination account must exist and be linked with mint. You can create it by using TokenProgram.createAccount.

Implementation

factory TokenInstruction.mintTo({
  required int amount,
  required Ed25519HDPublicKey mint,
  required Ed25519HDPublicKey destination,
  required Ed25519HDPublicKey authority,
}) =>
    TokenInstruction._(
      accounts: [
        AccountMeta.writeable(pubKey: mint, isSigner: false),
        AccountMeta.writeable(pubKey: destination, isSigner: false),
        // TODO(IA): this should be readonly unless, it is the fee payer
        AccountMeta.writeable(pubKey: authority, isSigner: true),
      ],
      data: ByteArray.merge([
        TokenProgram.mintToInstructionIndex,
        ByteArray.u64(amount),
      ]),
    );