Skip to main content

PSP35 Enumerable

This example shows how you can reuse the implementation of PSP35 token with PSP35Enumerable extension.

Step 1: Add imports and enable unstable feature

Import everything from openbrush::contracts::psp35::extensions::enumerable.

#![cfg_attr(not(feature = "std"), no_std)]

pub mod my_psp35 {
use openbrush::contracts::psp35::extensions::metadata::*;
use ink_prelude::string::String;
use ink_storage::traits::SpreadAllocate;

Step 2: Define storage

Declare storage struct and use EnumerableBalances instead of common balances to be able to use PSP35Enumerable extension in your PSP35 implementation.

#[derive(Default, SpreadAllocate, PSP35Storage)]
pub struct MyPSP35 {
psp35: PSP35Data<EnumerableBalances>,

Step 3: Inherit logic

Inherit implementation of the PSP35Enumerable trait. You can customize (override) methods in this impl block.

impl PSP35 for MyPSP35 {}

impl PSP35Enumerable for MyPSP35 {}

And that's it! Your PSP35 is now extended by the PSP35Enumerable extension and ready to use its functions! You can check an example of the usage of PSP35 Enumerable.

You can also check the documentation for the basic implementation of PSP35.