Questions tagged [pallet]

Questions about Runtime Modules built with the FRAME developer SDK.

Filter by
Sorted by
Tagged with
0 votes
1 answer
5 views

How do I hardcode asset id's?

Using pallet-assets, how do I create a pallet that has hardcoded (pallet-)asset id's for it's on-chain assets that the pallet handles? I wasnt able to find a good documented way to do this
user avatar
1 vote
0 answers
22 views

Getting Bad origin error in execution of the proposal?

I have integrated the democracy, collective, scheduler, and treasury pallet into my chain. Everything is working fine just during the end step when the proposal is executing it is giving me the bad ...
user avatar
0 votes
1 answer
21 views

Get value *AND KEY* from iter_prefix_values

I have a StorageNMap #[pallet::storage] #[pallet::getter(fn resources)] /// Stores resource info pub type Resources<T: Config> = StorageNMap< _, ( ...
user avatar
0 votes
1 answer
14 views

How do validators pass in custom data sets that is available for all applications to easily use?

Suppose we want to create a chain which has a native oracle "module" - is it possible to customize the validators to provide the information, or do we develop a pallet for this? In either ...
user avatar
  • 101
0 votes
0 answers
15 views

How to resovle the conflict in impl-trait-for-tuple version | nicks pallet tutorial

I am following the tutorial on substrate playground, and when I run the cargo check, I get the following compilation error: error: failed to select a version for `impl-trait-for-tuples`. ... ...
user avatar
5 votes
2 answers
76 views

Is there a Zkp pallet? or implementation?

I am looking for the application of ZKP protocols in Substrate. By looking around I've found a project called ZeroChain but it seems to be deprecated and no longer maintained. Are there any Substrate ...
user avatar
5 votes
1 answer
24 views

When using pallet-assets in another pallet: how to make pallet-assets calls private?

I'm using pallet-assets for my pallet, let's say custom-assets. In custom_assets::transfer I make some additional business logic and call pallet_assets::transfer. I want to make pallet_assets calls ...
user avatar
  • 51
1 vote
1 answer
22 views

into_sub_account(sub) encode the SAME adress for different sub

here is a simplified example of what i encounter: i have this function in my pallet: fn(...) -> ... { let idx = get_index(); // let address = T::PalletId::get().into_sub_account(idx); ...
user avatar
  • 141
1 vote
1 answer
17 views

Explanation on this syntax: pub trait Config<I: 'static = ()>: frame_system::Config

I was contributing on pallet-assets and I found it hard to understand this syntax: pub trait Config<I: 'static = ()>: frame_system::Config Care to explain in details and examples?
user avatar
2 votes
1 answer
23 views

Is it feasible to modify the contracts pallet to integrate it into a non-substrate rust-based blockchain?

Is it feasible to modify the contracts pallet to integrate it into a non-substrate rust-based blockchain? Say one that runs on Tendermint.
user avatar
0 votes
0 answers
19 views

Building my substrate pallet - Rust errors

I am a beginner at learning Rust/substrate/Polkadot. I am trying to build my custom substrate pallet My goal is, Create a custom Substrate pallet that allows only the Root origin account to control ...
user avatar
1 vote
1 answer
29 views

How does the democracy_pallet store a Vec<> in its storage?

I learnt that in storage, we can only have a fixed size for data structures, we cannot have a String, an array... So how, in democracy_pallet, they store a Vec<> and not a BoundedVec<> ? ...
user avatar
  • 141
2 votes
2 answers
146 views

Why is there a "lifetime" generic parameter in pallet_treasury?

I was wondering why, in treasury_pallet, there is a recurrent I generic parameter along with T, almost always used to specify lifetime: #[pallet::pallet] #[pallet::generate_store(pub(super) ...
user avatar
  • 141
0 votes
1 answer
19 views

After genesis has occurred how do I configure new pallet with pre-filled storage?

This question is somewhat similar to this question about configuring for testing but it is for an already live chain. In this scenario a new pallet will be added to an existing chain's runtime. The ...
user avatar
  • 220
4 votes
2 answers
128 views

What is a best way to fork a substrate pallet?

Context: i'm building a "sub-treasury" pallet, and for it, i'd like to start from the existing substrate's pallet_treasury. Problem: In Cargo.toml, there is relative paths (like sp-io = {...
user avatar
  • 141
1 vote
1 answer
45 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=...
user avatar
  • 134
0 votes
2 answers
51 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, ...
user avatar
  • 3
1 vote
1 answer
19 views

Is it possible to give Balance for transactions?

I know that transactions require certain fees to ensure the correctness of the network, but i was wondering if it is possible to do the reverse operation. I want to give users that send transactions ...
user avatar
  • 542
1 vote
1 answer
16 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: ...
user avatar
  • 134
0 votes
2 answers
52 views

Custom RPC parameters

I'm trying to return an item that is within a storageMap. Its key is a Vec(u8), but I don't know how to send this type using a curl call. I tried using the id as string and using its hex version and I ...
user avatar
  • 542
2 votes
1 answer
36 views

About pallet's account [duplicate]

I use pallet account in my pallet. pub const PALLET_ID: PalletId = PalletId(*b"abababab"); pub fn account_id() -> T::AccountId { PALLET_ID.into_account() } How can i get the ...
user avatar
  • 173
0 votes
0 answers
39 views

Serde::Serialize/Deserialize for BoundedVec

Do I have to manually Serialize/Deserialize BoundedVec? Update: There was no implementation, so I'm coding one here
user avatar
0 votes
1 answer
14 views

Client testing - simulate construct_runtime! and to include specific pallet into test runtime

I have client which works in parallel with custom pallet through Api implementation. To do proper testing I have to implement pallet for runtime similarly how construct_runtime! does to be able to ...
user avatar
0 votes
1 answer
21 views

Use Config as generic

I have declared pub struct Change<T: Config> { at my pallet. Hand made impl<T: Config> Clone for Change<T> { works fine, but when I'm adding #[derive(Clone)] to struct Change ...
user avatar
2 votes
1 answer
34 views

Testing for emojis in a Substrate Pallet

I have a pallet I'm working on that wants to deal with emojis (allowing emojis to be submitted, stored, etc). i found Rust crate unic_emoji_char which I think would help greatly, but can't get it to ...
user avatar
1 vote
1 answer
21 views

How can we use struct instead of tuple in pallet storage?

I am working on a pallet in which there is storage in which I am using a tuple. Can we use a struct instead of a tuple in the storage of pallet? if yes is there any reference to how we can use it?
user avatar
0 votes
1 answer
22 views

Setting static parameter types in benchmarks

There is very little information to be found on static parameter types. All I could find is a docstring that says: In testing, StaticArgument can be altered later: StaticArgument::set(8). I need to ...
user avatar
  • 173
1 vote
1 answer
23 views

Get last finalized block information from a pallet

Is it possible to retrieve the latest finalized block from a non-finalized block and its information? Using the Polkadot JS App we can check the chain state using the hash of the block, and using the ...
user avatar
  • 542
2 votes
1 answer
25 views

How to easily port the code for V3 pallets (early V3 syntax) to new syntax (4.0.0-dev)?

We have a lot of pallets that have early V3 syntax, example here: https://github.com/threefoldtech/tfchain/blob/development/substrate-node/pallets/pallet-burning/src/lib.rs We want to port them to the ...
user avatar
1 vote
1 answer
30 views

Error when implementing contracts pallet

Error message: error: failed to select a version for 'log'. ... required by package 'frame-benchmarking v4.0.0-dev (https://github.com/paritytech/substrate#580ebae1)' ... which satisfies git ...
user avatar
  • 59
0 votes
0 answers
18 views

sudo(bridgeRococoGrandpa.setOwner()) call resulting in BadOrigin error

I'm trying to set another owner for the messages and GRANDPA pallets, but I'm not succeeding while using the sudo account. I'm getting a sudo.Sudid BadOrigin error as a result. I've been told that ...
user avatar
  • 131
1 vote
1 answer
21 views

Why does my unit test pass when verifying signed metadata, but fails when signing through Polkadot.js

I have function that will take an admin account and verify when metadata is passed in that the admin account has signed it and the Signature is provided in a struct called NftSaleMetadata<AccountId,...
user avatar
  • 21
2 votes
1 answer
32 views

What is the meaning of pallet::compact in Pallet development

In this code, we can see the pallet::compact is used. So why we need this instruction? quotes code: #[pallet::weight(1_000)] pub fn transfer( origin: OriginFor<T>, ...
user avatar
1 vote
1 answer
37 views

What does `touch` method do in assets pallet?

I am currently looking at the assets pallet and I don't really understand what the touch method does. Hope someone can explain it to me. Thanks!
user avatar
  • 59
1 vote
1 answer
22 views

How to read the benchmark result?

A benchmark test for function with a param like this: runner_execute { let x in 1..10000000; ... let gas_limit_call = x as u64; }: { ... let call_runner_results = T::Runner::...
user avatar
2 votes
1 answer
41 views

How we can check the balance of the account in any pallet?

I am developing a pallet in which I need to check the balance of the account that is making the transaction. How can I check that?
user avatar
3 votes
1 answer
53 views

Transaction fee paying fund

I'm interested in systems where transaction fees can be paid for from a fund so that the end users don't have to deal with the chain's native token. This is what I've found so far: https://github.com/...
user avatar
  • 33
2 votes
1 answer
36 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 ...
user avatar
  • 411
8 votes
2 answers
86 views

how we can implement gasless/feeless transaction?

Do we have any reference how we can implement gasless/feeless transaction?
user avatar
7 votes
2 answers
64 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 ...
user avatar
  • 542
8 votes
3 answers
90 views

Error adding Custom RPCs for pallet

I've been trying to add some rpc calls available for my node, but an error related to the 'getrandom' module appears (even tho I'm not even using it). I have a very simple pallet that creates and ...
user avatar
  • 542
8 votes
2 answers
90 views

Transaction rollback in Substrate

As we know transactions on Ethereum are atomic. If something throws, everything rolls back. Do we have something similar in Substrate? Or all changes I should manually revert?
user avatar
1 vote
2 answers
54 views

How to reference the function with udf type parameters from another pallet in benchmarking

Pallet token: #[pallet::config] pub trait Config: frame_system::Config + pallet_balances::Config { type TokenId: Member + Parameter + AtLeast32BitUnsigned ...
user avatar
  • 11
6 votes
2 answers
59 views

Should events only be emitted in extrinsics?

Suppose my pallet implements a trait MyTrait so that it can be loosely coupled with another pallet. Suppose also that MyTrait::my_function() makes storage modifications, which I would like to notify ...
user avatar
  • 411
3 votes
1 answer
46 views

How to transfer funds via Currency(Balance Pallet) in ink! smart contract?

In ink! smart contract, we usually use AccountID and save the balances in array using mapping or HashMap. This is the traditional way of ERC20 smart contract. I am now developing on my local chain, ...
user avatar
5 votes
2 answers
75 views

How can I integrate ipfs with substrate node

I am trying to integrate ipfs in substrate-node-template, I came across https://github.com/rs-ipfs/substrate/tree/offchain_ipfs/bin/node-template, when I am trying to build it , getting many build ...
user avatar
  • 121
2 votes
1 answer
37 views

What is the benefit of using Serde::Serialize/Deserialize on defined types?

As an example, in the Kitties tutorial : #[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub ...
user avatar
2 votes
1 answer
23 views

substrate: missing generics for struct `pallet_democracy::GenesisConfig`

When attempting to build the Democracy pallet (pallet_democracy) within a runtime based on the polkadot-v0.9.15-1 branch, built native using Rust stable 1.57 and WASM using Rust nightly 2021-11-29, ...
user avatar
5 votes
2 answers
46 views

Is it possible to define a custom origin in my pallet?

The actors in my pallet are identified by the tuple (AccountId, CurrencyId) which requires most extrinsics to specify the CurrencyId enum as a separate argument. Example: #[pallet::weight(<T as ...
user avatar
3 votes
1 answer
39 views

Is ReservableCurrency or LockableCurrency a better fit for incremental bonding?

Here's what I am making: A pallet which "reserves" or "locks" some funds, incrementally each time a function X is called from an account. If I call X, 10 times, and my deposit fee ...
user avatar