burn static method

TransactionInstruction burn({
  1. required Pubkey account,
  2. required Pubkey mint,
  3. required Pubkey authority,
  4. List<Pubkey> signers = const [],
  5. required bu64 amount,
})

Burns tokens by removing them from an account. Burn does not support accounts associated with the native mint, use CloseAccount instead.

Keys:

Single owner/delegate

  • [w] account - The account to burn from.
  • [w] mint - The token mint.
  • [s] authority - The account's owner/delegate.

Multisignature owner/delegate

  • [w] account - The account to burn from.
  • [w] mint - The token mint.
  • [] authority - The account's multisignature owner/delegate.
  • [s] signers - The signer accounts.

Data:

  • amount - The amount of tokens to burn.

Implementation

static TransactionInstruction burn({
  // Keys
  required final Pubkey account,
  required final Pubkey mint,
  required final Pubkey authority,
  final List<Pubkey> signers = const [],
  // Data
  required final bu64 amount,
}) {
  // * Single owner/delegate
  // 0. `[writable]` The account to burn from.
  // 1. `[writable]` The token mint.
  // 2. `[signer]` The account's owner/delegate.
  //
  // * Multisignature owner/delegate
  // 0. `[writable]` The account to burn from.
  // 1. `[writable]` The token mint.
  // 2. `[]` The account's multisignature owner/delegate.
  // 3. ..3+M `[signer]` M signer accounts.
  final List<AccountMeta> keys = [
    AccountMeta.writable(account),
    AccountMeta.writable(mint),
    AccountMeta(authority, isSigner: signers.isEmpty),
    for (final Pubkey signer in signers) AccountMeta.signer(signer),
  ];

  final List<Iterable<u8>> data = [
    borsh.u64.encode(amount),
  ];

  return _instance.createTransactionIntruction(
    TokenInstruction.burn,
    keys: keys,
    data: data,
  );
}