DEV Community


Posted on • Updated on


List of common coding errors using Substrate

I have started to study Substrate recently, and encountered a lot of simple but not-so-easy to solve errors. So I decided to make a list of them, for future use and for others)

  • error[E0432]: unresolved import pallet
    This is compile error caused by errors in
    pub mod pallet { <fix errors here> }

  • error: failed to download parity-db v0.2.2
    can be resolved by:

cargo update -p parity-db
Enter fullscreen mode Exit fullscreen mode
  • many errors while building substrate-node-template often can be resolved with
cargo update -p <package causing problem>
Enter fullscreen mode Exit fullscreen mode
  • error
.iter().map(|x| x.amount).sum();
      the trait `Sum<<T as pallet_*::Config>::Balance>` is not implemented for `&<T as pallet_*::Config>::Balance`
Enter fullscreen mode Exit fullscreen mode

can be resolved by using

.fold(T::Balance::default(), |acc, x| acc + x);
Enter fullscreen mode Exit fullscreen mode

instead of .sum() OR if u use custom asset pallet and can make changes in it, adding trait Sum<Self::Balance> to Balance let u use .sum()

/// The units in which we record balances.  
type Balance: Member + Parameter + AtLeast32BitUnsigned + Default + Copy + Sum<Self::Balance>;
Enter fullscreen mode Exit fullscreen mode
  • error 1002 (in 1002: Verification Error: Runtime error: Execution failed: ApiError("Could not convert parameter tx between node and runtime: Could not decode Call::MyPallet.0:\n\tCould not decode Call::create.3:\n\t\tNot enough data to fill buffer\n")

This error appears because of wrong types.json - wrong type here: Call::create.3 - 3rd argument with start from 0 (0,1,2,3)

  • error

Top comments (0)

An Animated Guide to Node.js Event Loop

>> Check out this classic DEV post <<