Questions tagged [pallet]

Questions about Runtime Modules built with the FRAME developer SDK.

Filter by
Sorted by
Tagged with
2 votes
1 answer
25 views

error: cannot find macro `vec` in this scope [duplicate]

I'm working on substrate node template and their I have adding a pallet where I have added let votes = { Votes{ayes: vec![], nays: vec![]} }; in my pallet. for that I have also added use scale_info::...
2 votes
2 answers
60 views

How to write pallet rename data migration?

I want to rename one of our collective pallet instances to be visible in the PolkaddotJs App. I think the best option would be to migrate raw data. I assume that all pallet data has the same trie path ...
2 votes
1 answer
34 views

Balance division in Substrate runtime

I am a bit confused with how to do operations with the Balances in the Substrate runtime. More concrete the division. The example I want to implement is similar to the Lottery pallet but with shared ...
  • 1,039
-1 votes
1 answer
44 views

Error while running the RPC call

while running the flipper contract I get the following error { Err: { Module: { index: '9', error: '0x06000000' } } } What does it mean? I searched https://wiki.polkadot.network/docs/maintain-errors ...
2 votes
1 answer
15 views

Are pallet migrations triggered automatically by default or we need to pass each pallets migration explicitly in Executive Type?

Recently did a runtime upgrade on our node which broke all existing ink contracts. Later included the pallet contracts migration in Executive Type which fixed the issue. My impression was all runtime ...
1 vote
1 answer
18 views

how to test for storage leaks in pallets

Storage leaks in runtimes can be very damaging and cleaning up with a runtime update migration is non-trivial. I'd like to ensure the absence of storage leaks already in unit testing. My strategy ...
  • 403
0 votes
0 answers
32 views

Decode `AccountData`

I would like to create a custom RPC method to get the free balance for a specific account. I can get the data like that let mut data = &Account::<T>::get(who).data.clone(); and I see that ...
  • 81
0 votes
0 answers
16 views

Handling Democracy proposal execution

According to this answer, if I understood correctly, there are 2 ways to handle proposal execution when using the democracy pallet: through pallet-collective, or pallet-pre-image. I am trying to do ...
1 vote
1 answer
56 views

Democracy proposal not enacted

First of all I am working on Polkadot-v0.9.29. I am struggling to understand the right way to format a pallet call before submitting it as a proposal to the democracy pallet. Let's the pallet call be ...
1 vote
1 answer
20 views

Error when Adding weight related configurations

I'm in the process of configuring weights for a pallet pub struct GymWeight<T>(PhantomData<T>); impl<T: frame_system::Config> WeightInfo for GymWeight<T> { fn ...
  • 131
2 votes
1 answer
20 views

What is the meaning of trait `Member`?

Indeed, I don't understand this statement A type that can be used in runtime structures in docs: https://paritytech.github.io/substrate/master/sp_runtime/traits/trait.Member.html I noticed that some ...
  • 354
1 vote
2 answers
55 views

Implement MaxEncodedLen for Nested Origin

orml-authority implements a mechanism to allow origin to dispatch calls after and only after a delay. This is implemented using a pallet origin DelayedOrigin. The DealyedOrigin references the original ...
1 vote
1 answer
27 views

How we can test the vesting config given to chainspec.rs by unit testing?

I have added the vesting schedule/config to the and passed it to config of vesting pallet in chainspec.rs Can we test the vesting schedule/configs by unit test cases? if yes can you provide any sample
3 votes
2 answers
62 views

Different `OnTimestampSet` config for solo and para chains

I noticed that the OnTimestampSet differs in the parachains and solo chains. This config must be set in the solo chain as Aura or Babe. But in parachain, () is okay. In Cumulus: impl pallet_timestamp::...
1 vote
2 answers
44 views

Any example to using vesting pallet?

I have integrated the vesting pallet to my chain. Do we have any example how to use it and and how to prepare vesting config?
0 votes
2 answers
50 views

About passing Vec<u8> parameters in pallet

Problem How can I get the correct Vec<u8> in the pallet when I use Vec<u8> as the parameter of the pallet? code pub fn generate_proof_vkey( origin: OriginFor<T>, ...
  • 313
1 vote
1 answer
31 views

Event encoding in substrate pallet

Can two pallets have exactly same event name and event parameters. If yes then is there a way to distinguish the event came from which pallet in golang.
  • 21
0 votes
1 answer
15 views

How to avoid the wildcard Import?

I want to remove this wildcard import, but don't know how to do. I am working on the "pallet/xxx/src/lib.rs", while this file is very similar to the one from "substrate-node-template&...
  • 37
0 votes
1 answer
22 views

the trait bound `mock::Test: pallet_rmrk_core::Config` is not satisfied

I'm writing a pallet, which depends on pallet-rmrk-core, based on pallet-template. In lib.rs I wrote: #[pallet::config] pub trait Config: frame_system::Config + pallet_rmrk_core::Config { ...
  • 103
0 votes
1 answer
18 views

using getrandom with js feature cause conflict with app_crypto macro trying to use std types

I have two issues. The first: error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/...
  • 384
2 votes
1 answer
30 views

Substrate pallets structure

I wanted have through understanding of Substrate Pallet structure in general and the utility pallet in particular. If any one can please point me to some resource
4 votes
2 answers
111 views

SignedExtension to mutate Origin

Please see edits 2 and beyond, as they reshape the question a lot. TLDR: I need a way to mutate an origin for all but some specific calls so that it's dispatched as RawOrigin::Signed to pass ...
  • 95
0 votes
2 answers
39 views

What does #[pallet::compact] do?

What does #[pallet::compact] do?
1 vote
1 answer
34 views

Substrate Playground - Share workspace

I developed a custom pallet and I would like to allow to try it easily for others developers. Is it possible for me to share a Substrate Playground workspace and make it public? I found I can save a ...
2 votes
0 answers
35 views

Complete code flow understanding of substrate and frame pallets

As a substrate developer I have gained some experience in writing pallets, benchmarking extrinsincs and aggregating those to the runtime. But now I wanted to understand the system very deeply. I am ...
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
0 votes
1 answer
40 views

How to make calls with council origin?

In the tests of a pallet, I would like to use the council as the origin. I did the following: Imported the collective pallet Implemented pallet_collective::Config for Test: type CouncilCollective = ...
  • 373
0 votes
1 answer
39 views

How to return values from pallets?

This sounds to me like a silly question - but how do I actually return something from a pallet call? e.g. in the most basic example: #[pallet::weight(0)] pub fn get_answer_to_everything(_origin: ...
  • 175
1 vote
1 answer
55 views

how to get the current block author?

I am creating a new pallet, i have a simple task, get the current block author, i want to check whether I am the current one that is proposing the block or not by comparing the current block author ...
1 vote
3 answers
82 views

Where can I find more information of Gov2 specifications/documentation?

Other than the information presented (shown below), is there a way to keep track of the Gov2 technical specifications? https://polkadot.network/blog/gov2-polkadots-next-generation-of-decentralised-...
  • 113
0 votes
1 answer
57 views

Trying to get OneSessionHandler to trigger in custom pallet

I am trying to split our validators of a substrate chain into signing subgroups for key signing purposes. The OneSessionHandler gives me the perfect information I need to do this. On the end of each ...
0 votes
1 answer
38 views

What is the right way to remove a transaction-payment-pallet from the runtime?

After going through some of the posts here, as an experiment I tried removing the transaction-payment-pallet from the construct_runtime! to test if that would set all transaction fees to zero. However,...
  • 45
1 vote
1 answer
104 views

Invalid usage of `RuntimeEvent`

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 ...
0 votes
1 answer
14 views

How to use frame support FindAuthor trait in a custom pallet

I'm trying to use frame_support::traits::FindAuthor in my pallet for a custom logic. I imported the traits and I tried to loose coupling it. this is my config: #[pallet::config] pub trait Config: ...
  • 77
1 vote
1 answer
42 views

Token distribution to many users in substrate

I'm planning to write a pallet to distribute token to many users in substrate blockchain (Ex: 500k-1m users). Should I do a for loop in a user list and transfer token to them? Do you have any example?
1 vote
1 answer
51 views

How to use an outer mock inside `impl_benchmark_test_suite`?

Hey valuable Substrate pros, do you know a way to use impl_benchmark_test_suite inside another crate like the runtime? I have multiple pallets. There are no mocks inside these pallets. There is only ...
  • 157
4 votes
3 answers
374 views

How can I start a function automatically after a certain period of time?

I want to start a function automatically after a certain period of time in our chain. How can I do it?
0 votes
1 answer
54 views

How to create dex pallet? [closed]

I want to create dex pallet(without using pallet-contracts) with functionality like uniswap with pools of liquidity, this dex gonna work with my multi-token-pallet. So now I'm thinking about how to ...
0 votes
1 answer
29 views

How to loose couple trait with config?

I want to loose couple my MultiToken pallet to new Dex pallet, so I created MultiToken trait for interface. Here I need Config to infer AccountId and OriginFor types In my Dex pallet I need to add ...
0 votes
1 answer
32 views

How to get access to pallet storage from tests

I have approvals map in my pallet So when i try to get value from my storage, I'm getting this error So how to properly use pallet storage in tests?
0 votes
1 answer
20 views

How can I access a value obtained at runtime in primitives npos elections?

I want to change the weight/score of targets on the basis of values got during runtime, in my research I found the score of a target is being calculated in primitives/npos-elections/phragmen.rs in fn ...
0 votes
1 answer
31 views

panic_with_hook in session change

We are dealing with a runtime panic. We are looking for advice on how to best debug and are looking for help to get past it. At the change of an epoch we want a function to scan for a specific asset ...
  • 53
1 vote
1 answer
35 views

Test Case failing on on_initialize hook!

I'm writing a test case for the on_initalize hook! #[pallet::hooks] impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { fn on_initialize(_now: T::...
1 vote
2 answers
54 views

Delegating and undelegating during the lock period extends it for the initial amount

I'm trying to understand the following behaviour: A user delegates their vote (X DOT) with 1x conviction Then they change their delegation to a smaller amount (Y DOT) with the same 1x convinction ...
1 vote
1 answer
24 views

How to specify weight for call with loop

I have a loop in call which depends on array from arguments, so how can i specify weight to be multiplied to array length from arguments
3 votes
1 answer
79 views

How to remove storage item(vector data) automatically after a time interval?

I'm storing a vector of struct data inside a StorageValue, like this.. StorageValue<_, BoundedVec<RootClubForm<T>, T::MaxValue>, ValueQuery>; Is there any way I can automatically ...
1 vote
1 answer
52 views

Confused on terminology - Module/Pallet vs Crate vs Package

My elementary understanding is that a Crate is a collection of modules or pallets, and a Package is a collection of Crates. But I came across this "pallet" in crates.io and am now unsure why ...
  • 45
0 votes
1 answer
37 views

How to pass a String argument to a custom pallet function?

In the below code, I'm passing something of u32 type. How can I pass a text(String) instead of u32? pub fn do_something(origin, something: u32) -> dispatch::DispatchResult { ...
0 votes
1 answer
27 views

How to use code written in `std` in `no_std` during runtime?

I have a piece of code written in std, and it is bypassing/not-included in runtime as it should work but I want to use it in runtime environment, is there a way to use it. As the code written in std ...
0 votes
3 answers
74 views

How to mutate a `StorageDoubleMap` value?

I have StorageDoubleMap for ERC1155 balances u32 -> AccountId -> u32; How can I mutate this map like balances[1][SomeAccountId] -= 4?

1
2 3 4 5 6