Skip to main content

Burning Tokens

The burnToken method enables developers to permanently remove tokens from circulation within their blockchain application. This functionality is essential for managing the token supply, redeeming tokens, or other scenarios where reducing the number of tokens is necessary.


Overview of the burnToken Method

Token burning is a mechanism used to reduce the available supply of tokens, effectively removing them from the market. It can be used for various purposes, such as to create deflationary pressure on a token or to redeem tokens for assets or privileges within an application.


Prerequisites

  • Installed the edeXa-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 { ERC1155, Network } from 'edeXa-sdk';

async function burnToken() {
// Configuration settings for the ERC1155 instance
const settings = {
network: Network.SANDBOX, // Use Network.MAINNET for production environments
};

const erc1155 = new ERC1155({
...settings,
authorization: `Bearer ${token}`, // Replace `${token}` with your actual token
});

// Data required for the token burn operation
const dataToBurnToken = {
tokenId: 'uniqueTokenId', // Token ID of the tokens to be burned
value: 100, // Amount of tokens to be burned
chaincode: 'optionalChaincodeName', // Optional chaincode name
channel: 'optionalChannelName', // Optional blockchain channel
};

try {
// Perform the token burn operation
const burnTokenResponse = await erc1155.burnToken(dataToBurnToken);
// Handle success
} catch (error) {
// Handle error
}
}

Request Parameters

ParameterTypeRequiredDescription
tokenIdStringYesThe ID of the token to be burned.
valueNumberYesThe amount of tokens to be burned.
chaincodeStringNoThe name of the smart contract or chaincode managing the tokens.
channelStringNoThe name of the blockchain channel where the burn will occur.

Response Format

Upon successfully burning the tokens, the burnToken method returns a response object containing:

KeyTypeDescription
burnerstringThe username of the user who performed the burn operation.