ERC-20 Burnable
Extension of ERC-20 that allows token holders to destroy both their own tokens and those that they have an allowance for, in a way that can be recognized off-chain (via event analysis).
Usage
In order to make ERC-20 Burnable
methods “external” so that other contracts can call them, you need to implement them by yourself for your final contract as follows:
use openzeppelin_stylus::token::erc20::{
self, extensions::IErc20Burnable, Erc20, IErc20,
};
#[entrypoint]
#[storage]
struct Erc20Example {
#[borrow]
erc20: Erc20,
}
#[public]
#[inherit(Erc20)]
impl Erc20Example {
fn burn(&mut self, value: U256) -> Result<(), erc20::Error> {
// ...
self.erc20.burn(value)
}
fn burn_from(
&mut self,
account: Address,
value: U256,
) -> Result<(), erc20::Error> {
// ...
self.erc20.burn_from(account, value)
}
}