Questions tagged [frame]

Questions about Substrate's framework for developing custom runtime logic.

Filter by
Sorted by
Tagged with
5 votes
2 answers
175 views

<T::Lookup as StaticLookup>::Source vs T::AccountId?

I noticed https://github.com/paritytech/substrate/issues/6042 was recently resolved, replacing T::AccountId with <T::Lookup as StaticLookup>::Source. Substrate docs don't mention what is the ...
nazar-pc's user avatar
  • 539
1 vote
1 answer
60 views

Recommended layout for testing integration of pallets

I've been working on a pallet in isolation for a few months. I did testing by mocking a runtime and mocking the related pallets that are expected by it. Basically, so far I have created fake pallets ...
Angelo's user avatar
  • 501
1 vote
0 answers
64 views

What is the difference between Referenda and Democracy pallets?

Both Democracy and Referenda pallets are used for purposes of on-chain governance. However, only Democracy is used on Polkadot and Kusama runtimes. What is the difference between these two pallets?
Bernardo Rodrigues's user avatar
3 votes
0 answers
101 views

Cannot create a runtime on benchmark run

Using polkadot-v0.9.19 branch I've created benchmarks for a pallet, added it into runtime, compiled. On run of any of created benchmarks getting this error: Error: Service(Client(RuntimeApiError(...
Ivan Temchenko's user avatar
8 votes
1 answer
216 views

How does a Substrate chain set the max total supply?

How does a Substrate chain set the max total supply? Looking at the staking module, each era will increase the total_issuance through the issue. In the issue function, Self::Balance::max_value() is ...
Smith's user avatar
  • 131
0 votes
1 answer
23 views

Using ValueQuery gives error

Storage: #[pallet::storage] #[pallet::getter(fn voting)] pub type Voting<T: Config> = StorageMap<_, Twox64Concat, T::AccountId, Voter<T::AccountId>, ValueQuery>; Type: #[derive(...
Amiya Behera's user avatar
1 vote
1 answer
21 views

What are the arguments for api.query.childBounties.childBounties

In the documentation api.query.childBounties.childBounties takes two u32 arguments: But it is not clear what are those arguments. Can someone tell me how to map polkadot js api to substrate rust code ...
Nikhil Ranjan's user avatar
1 vote
1 answer
100 views

Bring and use sp-keystore and schnorrkel inside frame

I am writing a frame where I need to generate the vrf sign for the authority, this requires me to include the sp_keystore and schnorrkel in the cargo.toml of the frame. But then I encounter the ...
Yeou's user avatar
  • 219
3 votes
2 answers
383 views

access storage map from another pallet without trait pallet Config

I have one pallet with a storagemap that I want to use/call with another Pallet. After doing some research I ran over Centrifuge fudge project(https://github.com/centrifuge/fudge/blob/...
flipchan's user avatar
  • 319
2 votes
1 answer
262 views

Node that was not modified fails to build

I had a fully functioning node that was built about 4 day ago and I was using it. Today I've decided to rebuild it with cargo build -r and for some reason if failed to build with absolutely weird ...
CREESTL's user avatar
  • 474
3 votes
0 answers
59 views

How to do a manual implementation for 'AccountId'

I am working on creating a custom map which takes T::AccountId as a perimeter: #[pallet::storage] #[pallet::getter(fn declaration_map)] pub(super) type Declarations<T: Config> = StorageMap < ...
Jacgoldberg's user avatar
3 votes
1 answer
130 views

Using T::AccountId in a custom map

I would like to map T::AccountId to a custom struct I have Amendments <AccountId: #[pallet::storage] #[pallet::getter(fn declaration_map)] pub(super) type Declarations<T: Config> =...
Jacgoldberg's user avatar
0 votes
2 answers
63 views

How to create a subscription pallet?

As the title is descriptive, I would like to create a subscription pallet. A user needs to subscribe first and the receiver can receive the payment every month. Any idea how to design this pallet?
P.E's user avatar
  • 171
1 vote
3 answers
158 views

Inserting into a map of vectors

If I have a storage item defined as: pub Foo get(fn foo): map hasher(twox_64_concat) u32 => Vec<T::AccountId>; Do I always need to check if Foo contains the key before deciding to insert or ...
Nahu's user avatar
  • 337
10 votes
1 answer
177 views

Are Offences ever pruned?

In our runtime we have a custom implementation of offence reporting. I want to write an adapter for grandpa equivocation offences (implementing the ReportOffence trait), and have been using the ...
dan_chainflip's user avatar
3 votes
2 answers
237 views

How we can implement Governance in a chain?

I need to implement governance on my chain. Do we have any references which guide me in development?
Pankaj's user avatar
  • 1,896
2 votes
1 answer
122 views

Pallet Fails to Build Because of `std` Macros

I am currently facing this Error: Using rustc version: rustc 1.62.0-nightly (e85edd9a8 2022-04-28) Compiling frame-support v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=...
CREESTL's user avatar
  • 474
1 vote
2 answers
71 views

How to execute an ELF binary after a successful transaction

I am working on figuring out an efficient way to run an ELF binary after successful transaction. I also want to pass arguments along the execution. Example: /bin/ping 1.1.1.1 OCW might be a solution, ...
six's user avatar
  • 13
1 vote
1 answer
29 views

How to Implement sp_core:Encode?

I've copied Kulupu's difficulty pallet and tried to build my node after connecting the pallet. The decl_storage! macro in that pallet looks like this: decl_storage! { trait Store for Module<T: ...
CREESTL's user avatar
  • 474
7 votes
2 answers
109 views

How to change the number of heap pages

We are running into an allocator memory error where the number of heap pages appears to be insufficient to run a transaction on our validator (substrate-node). This is the error in question: 2022-04-...
shibshib's user avatar
  • 127
0 votes
1 answer
95 views

Question about Raw Origin in Frame System Pallet

Inside mod pallet {}, there is code for RawOrigin, which is pub enum RawOrigin<AccountId> { Root, Signed(AccountId), None, } I don't know how we can use this AccountId type ...
coco_yoon's user avatar
  • 119
7 votes
2 answers
414 views

Scalability beyond Asynchronous Backing

With the release of Asynchronous Backing, a good performance increase is expected (lower block time, increased block weight). Which further efforts are being undertaken with regards to Polkadot ...
Erasmus's user avatar
  • 71
6 votes
1 answer
119 views

How does `#[codec(mel_bound())]` work?

When declaring types, with generic parameters, to be stored in runtime storage, it’s common to see this pattern #[derive(Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct MyItem<TypeA, TypeB> ...
Angelo's user avatar
  • 501
0 votes
2 answers
198 views

Manually implement `Default` for `AccountId`

I am creating a parachain with a custom pallet, where i have this set up in storage: pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId; pub type NeuronMetadataOf<...
shibshib's user avatar
  • 127
6 votes
1 answer
202 views

Why is there no `Default` implementation for `T::AccountId`?

Starting with version 9.17 and greater I started getting these errors for the custom pallets I've made. Could I please get a pointer in resolving this issue? Example output from compiler: #[derive(...
Aaron Ely's user avatar
2 votes
1 answer
63 views

Transaction fails with account from an extension but OK with local account

I'm trying to figure out why my pallet UI produces wrong signatures when using Polkadot.js extension. UI is similar to https://polkadot.js.org/apps/#/signing: it calculates the signature over data ...
Denis Reshetov's user avatar
2 votes
1 answer
47 views

Do repeated reads of the same storage value add to the total weight?

I have an extrinsic with multiple calls to other pallet functions. As it calls other internal functions, more than one of them access the same storage value (either an actual StorageValue or the same ...
Angelo's user avatar
  • 501
4 votes
1 answer
75 views

Why do frame calls take a `Vec` parameter instead of `BoundedVec`?

I saw that some of the calls in frame take Vec as a parameter. I haven't found a call that takes BoundedVec, but my impression was that I should basically always use BoundedVec over Vec?
traceroute's user avatar
0 votes
1 answer
74 views

Runtime API to collect values in StorageMap

I'm trying to retrieve all values in my StorageMap defined as such in my pallet: #[pallet::storage] #[pallet::getter(fn submitted_tasks)] pub type SubmittedTasks<T: Config> = StorageMap<_,...
Mathis Wellmann's user avatar
0 votes
1 answer
68 views

Storing BTreeMap and Vec gives error

New substrate version requires derive MaxEncodedLen I have a following storage: #[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = &...
Amiya Behera's user avatar
2 votes
1 answer
122 views

How to use `IterableStorageMap`

So currently, I need to iterate over the StorageMap defined like this: pub(super) type Report<T: Config> = StorageMap<_, Blake2_128Concat, (T::AccountId, HealthRound), Reports<T::AccountId,...
Faisal Ahmed's user avatar
13 votes
2 answers
117 views

What are some good use cases for anonymous proxies?

There are some good conceptual explainers on what anonymous proxies are, yet it's not clear to me which use cases they serve best. What are some problems that using anonymous proxies would solve? What ...
Sacha Lansky's user avatar
  • 2,610
4 votes
1 answer
119 views

BTreeMap storage type

I would like to store a large amount of sorted integers, they should be traversable with efficient get and insert. If I can iterate over a storage map, could you let me know how? Or is there a ...
Saman H. Pasha's user avatar
2 votes
1 answer
67 views

How to create an escrow account without runtime upgrade

I'd like to create an account that is only usable through the root origin like the treasury account. It should be possible to transfer funds to it, but sending from it should only be possible through ...
Tino Rusch's user avatar
7 votes
2 answers
86 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 ...
andresvsm's user avatar
  • 1,104
5 votes
1 answer
31 views

Why does pallet-election-phragmen have a Balance field in it's Genesis Config?

Why does pallet-election-phragmen have a Balance field here? #[pallet::genesis_config] pub struct GenesisConfig<T: Config> { pub members: Vec<(T::AccountId, BalanceOf<T>)&...
Purple_Turtle's user avatar
1 vote
1 answer
36 views

Query on polkadot-apps chain-state cuts of string. Text-overflow?

Im trying to store a public key in a StorageValue, but when i try to consult it on polkadot-js chain-state, the string gets cut off in the following manner: KeyStart...KeyEnd The value being put in ...
Alexandre Silva's user avatar
4 votes
1 answer
134 views

How can I configure genesis state for my pallet's tests without hardcoding it?

I've been writing tests for pallet-kitties and have configured the genesis state inside my mock runtime by setting the storage items for two kitties (one Male and one Female) and their owners (with ...
Sacha Lansky's user avatar
  • 2,610
16 votes
1 answer
239 views

When to use `BoundedVec` vs. `WeakBoundedVec` vs. `Vec`?

Are there any guiding principles that can be applied to decide whether to use Substrate's BoundedVec, WeakBoundedVec, or Vec in a runtime? Is it a general rule of thumb to use the bounded variant ...
cmichi's user avatar
  • 2,755
3 votes
1 answer
132 views

Problem running assert_last_event in tests.rs

As the title suggests, I've been trying to call assert_last_event on the tests.rs class without success. The problem first happened when developing the kitties tutorial and after several toolchain ...
frkmnt's user avatar
  • 55
6 votes
1 answer
48 views

How i define a 1 to N relation in storage?

i'm trying to define a 1 to N storage relation in my pallet. I have a Resource (owned by an account ) which will be linked to N Use structs ( kind of a set ) - Account #1 --> Resource #A ...
Dark Forest's user avatar
4 votes
1 answer
117 views

Why is `DispatchResultWithPostInfo` expected?

The compiler: expected DispatchResultWithPostInfo It found: ) -> DispatchResult { I want to use DispatchResult and do not understand what the problem is. Additional context: #[frame_support::...
Joseph Mark's user avatar
9 votes
3 answers
115 views

How to limit the number of values by prefix in StorageDoubleMap?

Say I have a StorageDoubleMap that stores Data structs for each user and ContextId #[pallet::storage] pub type Info<T: Config> = StorageDoubleMap< _, Blake2_128Concat, ...
Angelo's user avatar
  • 501
2 votes
1 answer
99 views

Slashing and rewarding funds

I am trying to understand slashing and rewarding funds from the recipe example. https://substrate.recipes/currency-imbalances.html For slashing funds it doesn't require initialization with <...
Amiya Behera's user avatar
1 vote
3 answers
122 views

Substrate compatible crate for handling RSA encryption

Im working on a project where i want to store encrypted data on-chain and later reveal that data. For this process im thinking of using a trusted off-chain worker to act as a "key-manager". ...
Alexandre Silva's user avatar
3 votes
1 answer
80 views

Basics > Runtime > FRAME > Substrate FRAME Pallets

as a learner and beginner, I have 2 questions about the FRAME Pallets and especially to that overview: https://docs.substrate.io/v3/runtime/frame/--> Substrate FRAME PALLETS: The highlighted ...
Cindita's user avatar
  • 105
4 votes
3 answers
124 views

Basics > Runtime > FRAME > Modules (Runtime, System) / Difference?

I am a curious learner and on my way of understanding the core principles of the Substrate universe + going through the tutorials on substrate.io. As far as I understood is: there exists a Core ...
Cindita's user avatar
  • 105
2 votes
1 answer
120 views

When to use `compact` on extrinsic arguments?

I keep seeing #[pallet::compact] on some extrinsic arguments like here on the pallet-assets/mint definition: pub fn mint( origin: OriginFor<T>, #[pallet::compact] id: T::...
Oliver Tale-Yazdi's user avatar
2 votes
1 answer
114 views

testing pallet with ensure_root

I have written tests.rs and mock.rs everything is working except a function which has checks for root pub fn create_something( origin: OriginFor<T>, org: T::Hash ) -> ...
Boris Ivanov's user avatar
12 votes
2 answers
575 views

How to fix `parity_scale_codec::MaxEncodedLen` is not implemented for `T`?

When building my pallet, I run into the error: error[E0277]: the trait bound `T: parity_scale_codec::MaxEncodedLen` is not satisfied --> pallets/template/src/lib.rs:42:15 | 42 | #[pallet::...
Shawn Tabrizi's user avatar
  • 15.8k