Skip to main content

Questions tagged [macro]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
3 answers

Is it possible for users to call non #[pallet::call_index(0)] functions

Is this possible? Say you have a function in a pallet outside of the file that is a function like: impl<T: Config> Pallet<T> { pub fn tester(block: u64) { StorageElement::<...
Bob Linux's user avatar
  • 113
1 vote
1 answer

`The trait Deserialize is not implemented for a` GenesisConfig

I am in the process of upgrading a project from version 0.9.42 to 1.6.0, where the BuildGenesisConfig was added and BuildGenesis was deprecated, and I encounter an error (the trait Serialize is not ...
Benjamin Gallois's user avatar
2 votes
1 answer

How does the benchmarking code add_benchmarks! work on the runtime?

I am trying to understand the runtime-benchmarks gated code on the runtime/src/ and I realize that we need to "list" and "add" benchmarks that we want to perform : https://...
b0zero's user avatar
  • 533
3 votes
2 answers

What does #[pallet::compact] do?

What does #[pallet::compact] do?
Nikita Chernega's user avatar
1 vote
2 answers

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)...
Tbaut's user avatar
  • 253
2 votes
1 answer

Invalid generic declaration when using FRAME macro pallet::error

I want to add custom error types to a working pallet (permalink duniter-wot/src/ In this current state, cargo check pass successfully. According to Substrate documentation frame-macros/#...
Hugo Trentesaux's user avatar
1 vote
3 answers

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 ...
Bedeho Mender's user avatar
1 vote
1 answer

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? #[...
Bob Satikin's user avatar
0 votes
1 answer

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 file like this. #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; #[...
onigiri's user avatar
1 vote
1 answer

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 ...
ppoliani's user avatar
  • 111
4 votes
1 answer

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&...
Justin Frevert's user avatar
3 votes
1 answer

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, ...
JoshOrndorff's user avatar
  • 1,191
1 vote
2 answers

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/...
CREESTL's user avatar
  • 484
3 votes
1 answer

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)...
arx12's user avatar
  • 31
7 votes
2 answers

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 ...
andresvsm's user avatar
  • 1,114
6 votes
2 answers

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 don't include the second macro. The compiler ...
Mrisho Lukamba's user avatar