1

I am a beginner learning the substrate framework, So am actually following the documentation on the substrate website where it references the use of macros in a custom pallet, after implementing all the code, am facing some import errors, due to the lines posted below.

pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
    use frame_support::pallet_prelude::*;
    use frame_system::pallet_prelude::*;

Below is the complete error trace

    Compiling pallet-template v4.0.0-dev (/Users/mac/Desktop/pallet-identity/pallets/template)
  error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`.
    --> /Users/mac/Desktop/pallet-identity/pallets/template/src/lib.rs:11:1
     |
  11 | #[frame_support::pallet]
     | ^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: this error originates in the attribute macro `frame_support::pallet` (in Nightly builds, run with -Z macro-backtrace for more info)

  error[E0432]: unresolved import `pallet`
   --> /Users/mac/Desktop/pallet-identity/pallets/template/src/lib.rs:7:9
    |
  7 | pub use pallet::*;
    |         ^^^^^^ help: a similar path exists: `frame_system::pallet`

  For more information about this error, try `rustc --explain E0432`.
  error: could not compile `pallet-template` due to 2 previous errors

1 Answer 1

2

Outdated ~~Check your Cargo.toml. I think you missed the frame-support dependency.~~


After you updated the detail.

The main error is:

error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`.

So, follow the message to add the RuntimeEvent field back to your Config trait.

type RuntimeEvent: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

After taking a look at your source code.

I believe you have updated your Substrate version.

There is a breaking change.

Config::Event was renamed to Config::RuntimeEvent.

https://github.com/paritytech/substrate/pull/11981.


error[E0432]: unresolved import `pallet`

This error is because the macro will generate a mod pallet. But another error occurred while expending/executing the macro, so the mod pallet can not be generated. Thus, it reports can not find the pallet

6
  • the frame-support dependency is actually present frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } even the frame-system dependency is present too Oct 8, 2022 at 8:45
  • error[E0432]: unresolved import `pallet` was added to the error trace too. Oct 8, 2022 at 8:47
  • Could you put the full error log in the question? If there is a link to the code, that would be much better. Oct 8, 2022 at 8:47
  • I just added the error trace and this is a link to the code on github [github.com/jim-nnamdi/pallet-identity/blob/main/pallets/… ] (github) Oct 8, 2022 at 8:49
  • It looks like you updated your Substrate dependencies. Config::Event was renamed to Config::RuntimeEvent Oct 8, 2022 at 8:58

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.