1

I'm integrating my own pallet with Substrate's NFTs pallet. In my logic I try to create a collection with specific settings as follows:

let nft_collection_id = <T as Config<I>>::Nfts::create_collection(
                &who, 
                &who, 
                &CollectionConfig {
                    settings: CollectionSettings::from_disabled(
                        CollectionSetting::TransferableItems | CollectionSetting::DepositRequired
                    ),
                    max_supply: None,
                    mint_settings: MintSettings::default(),
                },
            )?;

This results in the error WrongSetting. I can say that the error is caused by DepositRequired, since everything works if I remove this setting. So I'm having a hard time trying to understand why I'm getting this error.

In the a test of the Nfts pallet itself a very similar thing is done:

let collection_id = 1;
        assert_ok!(Nfts::force_create(
            RuntimeOrigin::root(),
            account(1),
            collection_config_from_disabled_settings(
                CollectionSetting::TransferableItems | CollectionSetting::DepositRequired
            )
        ));

The only difference is that I'm using create_collection instead of force_create. Is that the reason why I'm getting this error?

1 Answer 1

0

In Substrate is a recomended security practice to take a deposit from the user for any storage items they place on chain.

The create_collection function you are calling uses a deposit to create a collection, so if you try to disable it throws an error. The force_create works because is a special extrinsic that can be called only with special privilegies(See the code)

        // DepositRequired can be disabled by calling the force_create() only
        ensure!(
            !config.has_disabled_setting(CollectionSetting::DepositRequired),
            Error::<T, I>::WrongSetting
        );

The deposit you have to reserve to create a collection is specified in the Config file of the NFT pallet:

/// The basic amount of funds that must be reserved for collection.
#[pallet::constant]
type CollectionDeposit: Get<DepositBalanceOf<Self, I>>;
1
  • This makes sense. Thanks for clearing this up. Commented Sep 19, 2023 at 6:34

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.