burn
The burn
function enables token holders to permanently remove or "burn" a specified quantity of their tokens, effectively reducing their circulation. Token burning serves various purposes, including decreasing the overall token supply or meeting specific protocol requirements. Typically, this method is found within objects or contracts that incorporate burning functionality, such as those adhering to ERC20
or ERC721
token standards.
Function Signature
async burn(amount: BigNumberish, signer: WalletSigner): Promise<string>
Parameters
amount
BigNumberish
The quantity of tokens the caller intends to burn. This value is specified in the smallest unit of the token (e.g., Wei for Ether). It can be provided as a number, string, or BigNumber.
signer
WalletSigner
The wallet signer instance responsible for signing the burn transaction. Usually created using methods like createWalletSigner
.
Returns
A
Promise
resolving to a string, typically representing the transaction hash indicating the status of the burn transaction on the blockchain.
Usage Example
Assuming you have a token or contract instance supporting the burn
method:
const burnAmount = "1000000000000000000"; // This represents 1 token, assuming 18 decimals
const signer = someMethodToCreateSigner("your private key"); // Replace with the appropriate method for signer creation
const transactionHash = await tokenInstance.burn(burnAmount, signer);
console.log(`Burn Transaction Hash: ${transactionHash}`);
Considerations
The
burn
operation permanently removes tokens from circulation, so ensure it's intended before executing. This action is irreversible.The
amount
specified for burning should be in the smallest divisible unit of the token. Always verify the conversions before initiating a burn.Due to security reasons, handle your private keys and the
signer
instance cautiously. Avoid exposing them in insecure or client-side environments.
Last updated