Questions tagged [rust]

Questions about the Rust programming language, the primary language used in the Substrate ecosystem.

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

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types

I am using the latest substrate-node-template few weeks back it was building fine. But the same project isn't building now, I did not do any changes. Error is occurring in runtime interface. I am ...
user avatar
-1 votes
0 answers
16 views

Adding babe pallet in node-template

I am trying to add babe pallet in node-template,as there is lots of dependency of other pallets in babe pallet like staking,authority-discovery etc.. so I added all those dependencies but i am facing ...
user avatar
1 vote
1 answer
32 views

(FIXED) Substrate forkless upgrade tutorial: pallet_scheduler has breaking changes [closed]

(This question was originally asked here: https://stackoverflow.com/questions/72056703/substrate-forkless-upgrade-tutorial-pallet-scheduler-has-breaking-changes) I am following the Substrate forkless ...
user avatar
  • 111
2 votes
1 answer
28 views

Scale codec: Is there a way to extract an enum's arm's codec index value?

Using scale, an enum can be written like this: #[derive(Debug, Clone, PartialEq, Eq, Encode, Decode)] pub enum Block { #[codec(index = 101)] V1(BlockV1), } The #[codec(index = 101)], the 101 ...
user avatar
0 votes
0 answers
17 views

How to enable breakpoints in IntelliJ

I am using IntelliJ as Ide for substrate development. I would like to enable breakpoints to debug it. How can I? Thank you!
user avatar
1 vote
1 answer
36 views

I want to understand this trait syntax

I want to understand this code. pub trait Trait: balances::Trait { type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>; } Could you please explain in ...
user avatar
1 vote
3 answers
39 views

How can manually generate same address from mnemonic as subkey without it?

Can someone tell me how can I generate a secret/privateKey/miniSecretKey, publicKey without subkey the tool from a mnemonic? I am working on a c# implementation of the wallet generation and I'd ...
user avatar
  • 21
1 vote
0 answers
31 views

Getting error in rust while compiling substrate node-template

I am trying to add the staking pallet with other dependencies in node-template and getting this error during compiling, I will be thankful if someone help me to resolve this issue
user avatar
0 votes
1 answer
24 views

Error expected struct `AccountId32`, found associated type when saving an AccountId who

I have a data structure as follows // definition for account id is // pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId; use primitives::{AccountId, ...
user avatar
  • 105
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
31 views

Rust ink! Utc::now() from chrono libary returns : function or associated item not found in `chrono::Utc'

as the title suggests. I imported chrono 0.4 just like in the documentation Here And when i ever i call Utc::now() to get current UTC time, i get error that the function now() doesn't not exists. Here ...
user avatar
1 vote
0 answers
52 views

Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts

as the title suggest, Im trying to call PSP22 token contract and read balanceOf() function, but i get error that im passing a too big of a input (27 instead of 8) Im trying to invoke balanceOf() PSP22 ...
user avatar
1 vote
1 answer
46 views

Cant submit an extrinsic signed by generated key pair

I was trying to submit items (extrinsics) to my Substrate blockchain instance, but it keeps getting rejected. I use the key pair I generate using from_string function from sp_core::crypto::Pair, but ...
user avatar
3 votes
1 answer
31 views

Which toolchain should I use to build Substrate

My current toolchains and targets look like this installed toolchains -------------------- stable-x86_64-unknown-linux-gnu (default) nightly-2022-01-01-x86_64-unknown-linux-gnu nightly-x86_64-unknown-...
user avatar
  • 134
1 vote
1 answer
48 views

Can we write bridge smart contract using ink?

I was reading about ink smart contracts and was curious is it possible to make bridge using ink, as there is already parity-common-bridges present. It would be very helpful if someone knows about this ...
user avatar
1 vote
1 answer
50 views

Substrate Rust generate key pair using sp_core::crypto::Pair

I'm pretty new with Substrate and Rust, but I was trying to generate a key pair using the from_string function of sp_core::crypto::Pair . I haven't had any luck and kept getting either ...
user avatar
3 votes
1 answer
44 views

How can I decode an extrinsic or event dynamically in rust?

How can I decode an extrinsic or event dynamically in rust? (I want to be able to decode across all parachains) A lot of the heavy lifting seems to be frame-metadata and scale-info. There's a desub ...
user avatar
  • 2,432
5 votes
1 answer
79 views

With subxt how can I subscribe to watch extrinsics?

There's some great examples of how to use subxt to listen to all events. Polkadot-js events screen seem to show events grouped by the extrinsic that created them. Can I do the same in rust? (if not ...
user avatar
  • 2,432
1 vote
0 answers
18 views

Best tools & settings for `VSCode` for *offline* Substrate development

Substrate builds are resource intensive. Running some of rust's best-in-class tools like rust-analyzer at least with default settings leads to continuous full use of most resources and take ...
user avatar
  • 1,232
1 vote
1 answer
35 views

Fetch storage data and convert it to primitive types with subxt

I want to get the bool value from the flipper contract. I use Rust and subxt. But I cannot convert it to a primitive type. let value: bool = api .metadata() .pallet("...
user avatar
1 vote
1 answer
37 views

How to resolve conflicted dependency versions when import frame_support

I'm trying to pull on-chain asset data from Basilisk via subxt. The name field of this asset_details struct is a BoundedVec and I need to be able to run the into_inner() method to get the vec from ...
user avatar
0 votes
1 answer
49 views

How to convert T::Moment to u64

Here is my code: #[derive(Clone, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct PayInstallmentOrder<Account, Balance, Time> { pub ...
user avatar
2 votes
0 answers
41 views

How to mint tokens in a particular account during runtime? [closed]

I am keeping track of the fee, been deducted in balances/lib.rs and want to mint it after the completion of era. My first question is how to keep track of era in balances pallet? and my main question ...
user avatar
1 vote
1 answer
52 views

trait bound `H256: TypeInfo` is not satisfied; `TypeInfo` is not implemented for `H256, H160, H64, ethereum_types::U256`

Frontier(pallet-ethereum) project failed to compile after updating from polkadot-v0.9.17 to v0.9.18 Compiling polkadot-runtime v0.9.18 (https://github.com/paritytech/polkadot?branch=release-v0.9....
user avatar
  • 461
3 votes
1 answer
38 views

How to create an iterator for a child storage trie?

I have a Storage Map which I am using to to store structs and a Storage Value to use for indexing this: #[pallet::storage] #[pallet::getter(fn consequences)] /// Storage map holding basic Consequence ...
user avatar
3 votes
1 answer
46 views

How do `subxt` and `substrate-api-client` libraries differ?

I understand that there are two main Rust client libraries for Substrate: subxt substrate-api-client I've checked out the examples for both libraries and it seems to me that they are mostly the same....
user avatar
  • 319
8 votes
3 answers
91 views

How to have a mapping in a custom structure inside an ink! contract?

I'm a newbie with rust and substrate. I'm currently trying to build a PSP34 compatible smart contract (NFT) for documents. In this contract, I'd like to have the following structure: #[derive(Default, ...
user avatar
6 votes
1 answer
37 views

How do I verify a signature signed using Polkadot.js app with rust code

I am trying to write a discord bot using rust/serenity to verify signature signed using polkadot.js app. I use schnorrkel crate, wrap the message in <Bytes>...</Bytes> and use the verify ...
user avatar
  • 63
4 votes
1 answer
35 views

Call a variable from [pallet::call] in another pallet [closed]

I have declared a variable in balances/lib.rs inside a [pallet::call] function. I want to call that variable at runtime in the staking pallet after the era completes. Or is there a way to call the ...
user avatar
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
1 vote
1 answer
34 views

How to output debug log in `build.rs`? [closed]

I want to output some debug info in the wasm_builder, What is the right way to do this? We cannot use normally runtime log::debug!(...) approach here, as the build.rs is compiled with the node build ...
user avatar
7 votes
1 answer
70 views

How to setup and RPC call that accepts a u128 input?

I cannot seem to setup a RPC call that accepts a u128 param. I can input the following let u128Input = new BN("10") let output = await api.rpc.template.testRpc(u128Input); but get an error ...
user avatar
  • 73
6 votes
1 answer
46 views

How to perform arithmetic operation on Option<BalanceOf<T>>?

Hello all developers and community members, I am very new to Substrate and Rust. I am creating a pallet for NFT marketplace. for storing out the NFT details I've created a struct as mentioned below. ...
user avatar
2 votes
1 answer
28 views

pallet-mmr-rpc missing impl

this is my service config. this is my rpc config. this is error message.
user avatar
  • 511
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
2 votes
1 answer
28 views

What is the difference between dependencies and dev-dependencies in Cargo.toml

My question is What is the difference between dependencies and dev-dependencies in Cargo.toml. And for developing pallet, now I have to declare crate in dependencies
user avatar
2 votes
2 answers
37 views

Attempting to build multiple runtimes, stopped by `AccountNonceApi_account_nonce` is already defined

Polkadot is capable of allowing you to defining the native runtimes you want included within the final node binary (with flags like polkadot-native, kusama-native and so on..). Attempting to port the ...
user avatar
9 votes
2 answers
121 views

Why do we need #![cfg_attr(not(feature = "std"), no_std)]

This attribute is applied to the item it is defined in and conditionally applies the no_std attribute if we are not using the "std" feature. Why do we need this and in which cases would the ...
user avatar
2 votes
2 answers
49 views

std in conditional compilation [closed]

#![cfg_attr(not(feature = "std"), no_std)] Does the "std" above reflect the rust standard library or the std feature defined in the cargo.toml for a given crate? Also, for many of ...
user avatar
6 votes
3 answers
81 views

Why is it a bad idea to use String in an ink! smart contract?

I've heard that it is a bad idea to use Rust's String type in an ink! smart contract. Why is this so? And what is your recommendation to use instead for typical use cases of String ‒ so parsing input ...
user avatar
7 votes
1 answer
36 views

Trait bounds not satisfied for `Balance` type

I was following this guide Configuring Genesis for Balances. In my parachain, I replaced T::Balance with BalanceOf<T> type BalanceOf<T> = <<T as Config>::Currency as ...
user avatar
  • 461
5 votes
1 answer
43 views

How to programmatically get current unbonding information on the Polkadot relay chain?

Using either a Rust or JavaScript client library I would like to get the amount of DOT that is currently being unbonded on the relay chain. Some staking information is available in the Polkadot JS ...
user avatar
  • 319
0 votes
1 answer
28 views

error: duplicate lang item in crate `std` (which `arrayvec` depends on): `panic_impl`

I am use the latest rust toolchain, compiler the pallet-ibc at the branch feature/dv-ics20 : https://github.com/octopus-network/substrate-ibc, this give the blow error. suyinrong@suyinrongdeMacBook-...
user avatar
2 votes
1 answer
34 views

T::Balance ... associated type `Balance` not found for `T`

I was following this guide: Configuring Genesis for Balances https://docs.substrate.io/how-to-guides/v3/basics/genesis/ but got this error: associated type Balance not found for T, associated type ...
user avatar
  • 461
2 votes
2 answers
30 views

How can I have some of the functions in separate file?

I want to keep some helper functions in a separate file. How can I do that? impl<T: Config> Pallet<T> { fn get_citizen_accountid(citizenid: u128) -> fn get_citizen_id(...
user avatar
3 votes
1 answer
79 views

How to return the whole Mapping from a contract method?

I'm a newbie in Rust, Substrate, and blockchain development. I'm developing an ink! smart contract that store a list of items. Since the storage version of Vec is not available yet, I use a Mapping to ...
user avatar
1 vote
3 answers
57 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". ...
user avatar
5 votes
3 answers
73 views

Missing trait problem

Hello the following code snippet is giving me headaches: mod items; pub use super::*; pub use crate::roles::items::*; pub type BalanceOf<T> = <<T as pallet::Config>::Currency as ...
user avatar
5 votes
1 answer
54 views

Cannot infer type for type parameter 'T'

I have a function using the following 2 types: pub type BalanceOf<T> = <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; pub ...
user avatar
0 votes
2 answers
46 views

How to match the versions or Susbstrate upstream in my project's dependancies? [closed]

I'm new to substrate and follow this tutorial: https://docs.substrate.io/tutorials/v3/kitties/pt1/. I'm facing problem in this line : we'll need to import serde. Add this to your pallet's Cargo.toml ...
user avatar