TokenInstruction.burnChecked constructor

TokenInstruction.burnChecked({
  1. required int amount,
  2. required int decimals,
  3. required Ed25519HDPublicKey accountToBurnFrom,
  4. required Ed25519HDPublicKey mint,
  5. required Ed25519HDPublicKey owner,
  6. List<Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[],
})

Burns tokens by removing them from an account.

TokenInstruction.burnChecked does not support accounts associated with the native mint, use TokenInstruction.closeAccount instead.

This instruction differs from TokenInstruction.burn in that the decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Implementation

factory TokenInstruction.burnChecked({
  required int amount,
  required int decimals,
  required Ed25519HDPublicKey accountToBurnFrom,
  required Ed25519HDPublicKey mint,
  required Ed25519HDPublicKey owner,
  List<Ed25519HDPublicKey> signers = const <Ed25519HDPublicKey>[],
}) =>
    TokenInstruction._(
      accounts: [
        AccountMeta.writeable(pubKey: accountToBurnFrom, isSigner: false),
        AccountMeta.writeable(pubKey: mint, isSigner: false),
        AccountMeta.writeable(
          pubKey: owner,
          isSigner: signers.isEmpty,
        ),
        ...signers.map(
          (pubKey) => AccountMeta.readonly(pubKey: pubKey, isSigner: true),
        ),
      ],
      data: ByteArray.merge([
        TokenProgram.burnCheckedInstructionIndex,
        ByteArray.u64(amount),
        ByteArray.u8(decimals),
      ]),
    );