Triggers the burn token flow. This means sending the token to a burn address which makes it non recoverable.

📘

If a user has not connected their wallet, burn() will automatically call connect().

Parameters

NameTypeRequiredDescription
tokenIDNumberYA specific token to burn.
amountNumberNDefault value is set to 1. For ERC 721 it can only take 1 as a number since every tokenId has one copy. For ERC 1155 it can take a larger amount depending on the number of tokens someone wants to burn.
waitBooleanNDefault value is set true. Blocks the return of this function until the transaction has completed on network by calling waitForTransaction() . Note that the transaction may take a while to resolve depending on network traffic.

Responses

//if wait is set to true
{
  "hash": "string",
  "transactionStatus": "string" //Complete or Failed 
}
//if wait is set to false
{
    "hash": "string"
}

Example Usage

const amount= 1;
const waitForTransaction = true;
const tokenId = 1

// ERC721
const transaction = await contract.burn(tokenId,amount,waitForTransaction);

// ERC1155
const transaction = await contract.burn(tokenId,amount,waitForTransaction);

// Optional (if waitForTransaction is false)
const status = await contract.getTransactionStatus(transaction);

Possible Usage

All errors are prefixed with HM (burn) -

  • Token Not In Wallet- Error while executing burn either you do not have the token in your wallet or something has gone wrong
  • Errors in the connect() function

Feedback

Something not quite right, unclear or can't find what you are looking for? Please let us know at support.moonpay.com and we will get back to you as soon as we can.