0

Error "StorageDepositLimitExhausted" occurs when trying to mint

But I don't know why this error happens

The code is here

#![cfg_attr(not(feature = "std"), no_std)]
#![feature(min_specialization)]
        
#[openbrush::contract]
pub mod my_psp22 {
    
    // imports from openbrush
    use openbrush::traits::Storage;
    use openbrush::contracts::psp22::extensions::mintable::*;

    #[ink(storage)]
    #[derive(Default, Storage)]
    pub struct Contract {
        #[storage_field]
        psp22: psp22::Data,
    }
    
    // Section contains default implementation without any modifications
    impl PSP22 for Contract {}
    impl PSP22Mintable for Contract {}
     
    impl Contract {
        #[ink(constructor)]
        pub fn new(initial_supply: Balance) -> Self {
            let mut _instance = Self::default();
            _instance._mint_to(_instance.env().caller(), initial_supply).expect("Should mint"); 
            _instance
        }
        #[ink(message)]
        pub fn mint_to(&mut self, account: AccountId, amount: Balance) -> Result<(), PSP22Error> {
            self.mint(account, amount)
        }
    }
}

When I execute "mint_to" message by the caller of contract executed account, it's OK enter image description here

But when I execute "mint_to" message by the caller of the other account, the error occurs.

enter image description here

I don't understand why this error happen.

I would be glad if someone could tell me what it is.

1
  • Does the calling account (test2) have enough funds?
    – forgetso
    Mar 7, 2023 at 12:02

1 Answer 1

1

The error likely happens because your test2 account does not have enough funds to pay for the storage deposit.

For pallet-contracts / ink! the caller always needs to pay a deposit for any storage that will be created on-chain with the invoked message. This deposit is returned to whoever frees up the storage again.

You should check in polkadot-js if your account has enough funds.

1
  • 1
    Thank you! Your answer is correct! You're a big help, thank you!
    – 2020 yuki
    Apr 17, 2023 at 5:05

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.