Skip to main content

burn

The burn method, commonly found in some ERC-721 token implementations, allows for the permanent removal of a non-fungible token (NFT) from circulation. Once a token is burned, it can no longer be transferred, and its data is effectively deleted. This action is irreversible. The burn method is part of the ERC721Instance object, obtainable through the appropriate client library (e.g., EdexaClient or equivalent).

Method Signature

async burn(tokenId: string, signer: WalletSigner): Promise<TransactionResponse>

Parameters

ParameterTypeDescription
tokenIdstringThe unique identifier of the ERC-721 token you wish to burn.
signerWalletSignerThe wallet signer instance used for signing the burn transaction. Typically associated with the token's owner.

Returns

  • A Promise resolving to a TransactionResponse object, which provides details about the burn transaction, including its status, transaction hash, and more.

Usage Example

First, instantiate the desired ERC-721 token contract:

const erc721 = edexaClient.getERC721Instance("your ERC-721 contract address here");

Then, use the burn method to destroy a specific token:

const tokenId = "12345"; // Example token ID
const signer = edexaClient.createWalletSigner("your private key");
const transactionResponse = await erc721.burn(tokenId, signer);
console.log(`Burn Transaction Hash: ${transactionResponse.hash}`);

Notes

  • Burning a token is irreversible. Ensure you truly wish to remove the token from circulation before calling the burn method.

  • Only the owner of the token or an approved address can burn the token. Attempting to burn a token without the necessary permissions will result in a failed transaction.

  • As with all transactions on the Ethereum network, burning a token may require gas. Ensure the account associated with the signer has enough edeXa coin to cover transaction fees.