DEV Community

nikania
nikania

Posted on • Edited on

3 3 1 1 1

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 polkadot.js.org/apps/) 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

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay