0

As the title states, is it possible, to burn tokens that are in the balance of a contract? I made a mini game where the person who calls the external function, it suppose to burn the tokens in the contracts balance. I made 1 external function, that is the function for the user to call and 1 internal function that is executed when the external function is called. I did this on purpose, so that msg.sender is the contract. However, i receive unsufficient allowance when the external function is called. But why is allowance needed? The msg.sender for the internal call will be the contract its self, since when does it needs allowance for its self?

Is it even possible to get it working, to make a user call a function in the contract, that makes the contract burn its token balance?

1 Answer 1

0

Yes, contract can burn the tokens if the token has implemented burning system. Generally any burnable token provide 2 functions to burn the tokens.

That are:

  1. burn(uint256 amountToBurn)
  2. burnFrom(address sender, uint256 amountToBurn)

If you or contract want to burn its own tokens then you would call burn(uint256 amounToBurn) function then burning will happen from your wallet or the wallet (contract) that is calling this function. But if you or contract want to burn from on behalf of other than you would call burnFrom(address sender, uint256 amountToBurn) in this case the sender should approve allowance to you or the one who is calling this function.

In case of burn function allowance is not needed because the caller is burning its own token.

Finally, it depends upon the implementation of the burn function. The standard way is as described above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.