Questions tagged [macro]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
39 views

What does #[pallet::compact] do?

What does #[pallet::compact] do?
1 vote
2 answers
79 views

The ensure! macro with a false condition doesn't make an extrinsic fail, why?

In the code of the Nicks pallet, there is some logic to make sure the name passed as parameter is long enough. ensure!(bounded_name.len() >= T::MinLength::get() as usize, Error::<T>::TooShort)...
  • 41
2 votes
1 answer
20 views

Invalid generic declaration when using FRAME macro pallet::error

I want to add custom error types to a working pallet (permalink duniter-wot/src/lib.rs). In this current state, cargo check pass successfully. According to Substrate documentation frame-macros/#...
1 vote
3 answers
35 views

Mixing FRAME macros in a single runtime or pallet

There has been an evolution in how one defines pallets in the Substrate framework over time, and this has left the ecosystem in a state where useful pallets exist in different versions. This begs the ...
0 votes
1 answer
47 views

Why getter function don't return Result type?

I'm using #[pallet::getter(fn get_balance)] for my StorageMap to generate a getter function, but it returns pure u64 instead of Result type. What is the way to handle missing key cases then? #[...
0 votes
1 answer
48 views

Error in Substrate "use macros in a custom pallet" tutorial

I'm currently trying this substrate tutorial, but it got stuck. Following the tutorial, I coded lib.rs file like this. #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; #[...
1 vote
1 answer
24 views

Organize Runtime into modules

In the examples I've seen so far I can see that all the [pallet::*] definitions are within the #[frame_support::pallet] module. Is there any way we can split these into separate modules? For example ...
  • 111
4 votes
1 answer
67 views

Expose StorageItems to other pallets whose types are bound on an instance of my pallet

I have a pallet pallet-a whose StorageItem should be read/written by other pallets. Let's say that StorageItem is #[pallet::storage] #[pallet::getter(fn get_commitments)] pub type Commits&...
3 votes
1 answer
55 views

Why do runtime APIs have a block_height parameter on the client side but not on the runtime side?

Runtime APIs are declared using the decl_runtime_api! macro. This is typically in a primitives crate. For example: decl_runtime_apis! { pub trait ExampleApi { fn get_info(param1: u32, ...
1 vote
2 answers
87 views

Problems With `app_crypto!` Macro

I have the following error while building: error[E0599]: no function or associated item named `generate_with_phrase` found for struct `crain_pow::app::Pair` in the current scope --> node/src/...
  • 414
3 votes
1 answer
25 views

Adding PaysFee to #[pallet::weight("")] produces unexpected token error

I'm working with the node template and I want a particular type of extrinsic to not have to pay a fee. I followed these instructions but whenever I add another value to the "pallet::weight(10_000)...
  • 31
7 votes
2 answers
77 views

What are the differences between using declarative and attribute macros in FRAME?

What's the main difference (besides the code) between using the decl_storage! macro rule and using the [pallet::storage] macro? I've seen pretty much everyone using macro rules, but on the latest ...
  • 957
4 votes
1 answer
103 views

What is the role of `#[scale_info(skip_type_params(T))]`?

#[derive(Encode,Decode,TypeInfo) #[scale_info(skip_type_params(T))] Pub struct Asset<T:Config> { Id:### Name:## } So in the above example if you dont include the second macro. The compiler will ...