1

I tried to follow this tutorial but I have the following problem:

This is my pallets/template/src/lib.rs file on github

And this is the pallets/template/Cargo.toml file on github

The terminal error output:

error: expected one of: `generate_store`, `without_storage_info`, `storage_version`
  --> pallets/template/src/lib.rs:40:12
   |
40 |     #[pallet::generate_storage_info]
   |               ^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared crate or module `sp_std`
 --> pallets/template/src/lib.rs:5:5
  |
5 | use sp_std::vec::Vec;
  |     ^^^^^^ use of undeclared crate or module `sp_std`

error[E0432]: unresolved imports `pallet`, `sp_std::vec::Vec`
 --> pallets/template/src/lib.rs:4:9
  |
4 | pub use pallet::*;
  |         ^^^^^^ help: a similar path exists: `frame_system::pallet`
5 | use sp_std::vec::Vec;
  |     ^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `pallet-template` due to 3 previous errors

I'm pretty new to Rust and Substrate so I don't get what is the problem here.

UPDATE

I remove #[pallet::generate_storage_info] as suggest by @shawn-tabrizi now I get only this two errors:

error[E0433]: failed to resolve: use of undeclared crate or module `sp_std`
 --> pallets/template/src/lib.rs:5:5
  |
5 | use sp_std::vec::Vec;
  |     ^^^^^^ use of undeclared crate or module `sp_std`

error[E0433]: failed to resolve: use of undeclared crate or module `sp_std`
  --> pallets/template/src/lib.rs:11:9
   |
11 |     use sp_std::vec::Vec; // Step 3.1 will include this in `Cargo.toml`
   |         ^^^^^^ use of undeclared crate or module `sp_std`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `pallet-template` due to 2 previous errors
5
  • Could you share the code via GitHub? Then its easier to help. The documentation about the generate_storage_info is outdated, you can replace it with the beginner-friendly without_storage_info. Commented Jul 21, 2022 at 8:15
  • Thank you for answering, I just edit the question with link to the forked repo files. Ok I will try to change in this without_storage_info
    – viac92
    Commented Jul 21, 2022 at 8:54
  • 1
    You can actually just delete generate_storage_info and not add without_storage_info. This would be better.
    – Shawn Tabrizi
    Commented Jul 21, 2022 at 9:55
  • can you share the cargo.toml file? there is probably a mistake in there
    – Shawn Tabrizi
    Commented Jul 21, 2022 at 10:15
  • 1
    It is in the initial question but here the link
    – viac92
    Commented Jul 21, 2022 at 10:17

1 Answer 1

3

The problem is that you placed sp-std import into the dev-dependencies rather than the regular dependencies.

Your file should like:

[package]
name = "pallet-template"
version = "4.0.0-dev"
description = "FRAME pallet template for defining custom runtime logic."
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
homepage = "https://substrate.io/"
edition = "2021"
license = "Unlicense"
publish = false
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
    "derive",
] }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
frame-support = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26"}
frame-system = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
frame-benchmarking = { default-features = false, version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26", optional = true }
# PUT IT HERE
sp-std = { default-features = false, version = "4.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }

[dev-dependencies]
sp-core = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
sp-io = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
sp-runtime = { default-features = false, version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.26" }
# DON'T PUT IT HERE

[features]
default = ["std"]
std = [
    "codec/std",
    "scale-info/std",
    "frame-support/std",
    "frame-system/std",
    "frame-benchmarking/std",
    'sp-std/std',
]

runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
try-runtime = ["frame-support/try-runtime"]
1
  • 1
    Thank you, I just started from the beginning and now it works. Also the new versione of the tutorial is a lot better.
    – viac92
    Commented Aug 4, 2022 at 11:16

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.