Skip to main content

burnFrom

The burnFrom method is designed to permit a user (or contract) to burn or destroy a specified quantity of tokens from another user's account. This action requires the prior consent of the token owner, usually obtained via the approve method. The capability to burn tokens from another user's account can be incorporated in specific token contracts for particular use cases, such as staking or governance scenarios.

Method Signature

async burnFrom(from: string, amount: BigNumberish, signer: WalletSigner): Promise<string>

Parameters

ParameterTypeDescription
fromstringThe Ethereum address from which the tokens are to be burned.
amountBigNumberishThe amount of tokens to be burned, given in the smallest unit of the token (e.g., Wei for Ether). It can be represented as a number, string, or BigNumber.
signerWalletSignerThe wallet signer instance in charge of signing the burn transaction. It is commonly created using methods like createWalletSigner.

Returns

  • A Promise that resolves to a string, typically indicative of the transaction hash corresponding to the burn operation.

Usage Example

Assuming the appropriate token contract is already instantiated:

const fromAddress = "0xF6E234C71F1bB45ABa51c977137eF090b2df2Fe5";
const burnAmount = "1000000000000000000"; // Representing 1 token, given an 18-decimal precision
const signer = edexaClient.createWalletSigner("your private key");

const transactionHash = await erc20.burnFrom(fromAddress, burnAmount, signer);
console.log(`Burn Transaction Hash: ${transactionHash}`);

Notes

  • Before executing the burnFrom method, ensure the from address has set a sufficient allowance for the signer via the approve method.

  • Always remember that the amount is delineated in the smallest divisible unit of the token. It's crucial to manage conversions accurately.

  • As a security best practice, maintain the confidentiality of your private keys and exercise caution when using the signer in potentially insecure environments.