Burning Tokens
Burning tokens is an irreversible process of permanently removing tokens from circulation. The edeXa ERC721 SDK's burnToken
method facilitates this process, allowing developers to effectively manage the supply of non-fungible tokens (NFTs) in their applications.
Overview of the burnToken
Method
The burnToken
method enables the destruction of NFTs, identified by their unique token ID. This operation is critical for applications that require the ability to withdraw tokens from the ecosystem, either to correct minting errors or to adjust the total supply.
Prerequisites
- Installation of the edeXa ERC721 SDK in your project.
- An authentication token obtained through the SDK's authentication method. This token is necessary to authorize your requests.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the burnToken
method:
import { ERC721, Network } from 'edeXa-sdk';
async function burnToken() {
const settings = {
network: Network.SANDBOX, // Use Network.MAINNET for production environments
};
const erc721 = new ERC721({
...settings,
authorization: `Bearer ${token}`, // Replace `${token}` with your authentication token
});
const dataToBurnToken = {
tokenId: 'Enter the tokenId you want to burn',
chaincode: 'Optional smart contract name', // Managing tokens' smart contract name
channel: 'Optional blockchain channel name', // Blockchain channel name
};
try {
const burnTokenResponse = await erc721.burnToken(dataToBurnToken);
// Handle success
} catch (error) {
// Handle error
}
}
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
tokenId | Yes | Number | The unique identifier of the token to be burned. |
chaincode | No | String | Name of the smart contract managing the tokens (optional). |
channel | No | String | Name of the blockchain channel (optional). |
Response Format
Upon successful execution, the burnToken
method returns a response that includes the identity of the entity that performed the burn operation.
Attribute | Type | Description |
---|---|---|
burner | String | The username or identifier of the entity that burned the token. |