1

I'm new to Substrate and I'm creating a pallet in which the user can create contests by depositing a certain amount of assets. My idea is to send that amount to the PalletId account, but I'm having an error "Err(Token(CannotCreate))" when testing, and it's happening in the following function:

T::Assets::transfer(
  prize_token_id,
  &who,
  &Self::account_id(),
  prize_token_amount,
  false
)?;

I didn't find it when I tried to see if anyone had something like this. I know the error is related to providers and consumers, but I couldn't relate it to my problem.

What could be happening to throw this error?

EDITED:

The repo is here: https://github.com/pablolteixeira/constests-unit-network/blob/main/substrate-node-unitchain/pallets/contests/src/lib.rs

On line 240, it's possible to find the "transfer" function that is panicking.

cargo test -p pallet-contests is sufficient to see the error happening.

1
  • 1
    Need more context. Which pallets are you using? Please include the repo for your code. Ideally also include steps to reproduce the error.
    – Bruno
    Mar 18 at 21:14

2 Answers 2

1

Without more context, this could be your issue:

The tokens trait has an DepositConsequence enum which one of its variants is CannotCreate which means:

Deposit cannot happen since the account cannot be created (usually because it’s a consumer and there exists no provider reference).

1

Check if your pallet account has enough native balance. If it has less than existential balance this error can occur

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.