ERC-1155 Burnable
Extension of ERC-1155 that allows token holders to destroy both their own tokens and those that they have been approved to use.
Usage
In order to make ERC-1155 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::erc1155::{
extensions::IErc1155Burnable, Erc1155,
};
#[entrypoint]
#[storage]
struct Erc1155Example {
#[borrow]
pub erc1155: Erc1155,
}
#[public]
#[inherit(Erc1155)]
impl Erc1155Example {
fn burn(
&mut self,
account: Address,
token_id: U256,
value: U256,
) -> Result<(), Vec<u8>> {
// ...
self.erc1155.burn(account, token_id, value)?;
// ...
}
fn burn_batch(
&mut self,
account: Address,
token_ids: Vec<U256>,
values: Vec<U256>,
) -> Result<(), Vec<u8>> {
// ...
self.erc1155.burn_batch(account, token_ids, values)?;
// ...
}
}