Questions tagged [rust]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
165 views

Emiting events does not work with cross contract calling

When using cross contract calling on another contract which also emits events the events of the original contract do not work anymore. I get the following error. error[E0283]: type annotations needed ...
rajohs's user avatar
  • 491
0 votes
2 answers
122 views

How to add and use a crate in an ink smart contract/ ink storage?

I want to use the bytes crate in an ink! smart contract of mine. Also I want to declare a Byte value in the ink_storage struct. However, I cannot figure out how to do this. After hours of trying and ...
rajohs's user avatar
  • 491
1 vote
1 answer
82 views

Unable to calculate logarithm of a number error method log10 ln

when I tried to get a logarithm of a number Im getting following erros in Substrate how to fix this ? 437 | let cc = f32::log10(4 as f32); | ^^^^^ function or ...
not 0x12's user avatar
  • 343
2 votes
1 answer
86 views

Error building node template: file name too long

I'm trying to build the latest substrate node template (without any modifications so far) and I'm getting the following error: error: failed to run custom build command for `node-template-runtime v4.0....
Adam Wierzbicki's user avatar
2 votes
1 answer
250 views

How to decode events help on substrate using polkadot.js?

I have a base smart contract in rust with package manager cargo. In that smart contract I have some events which I'm emitting while function calling. For listing that events I have a service in java ...
Puneet Jindal's user avatar
1 vote
1 answer
23 views

Why does substrate extrinsic return a unit tuple ? What is the significance of that?

Most of return types are result with a success of a unit tuple, Like In rustic perspective, what is the significance of this?
Mrisho Lukamba's user avatar
4 votes
2 answers
877 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 ...
Vjendra Gaorh's user avatar
1 vote
1 answer
58 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 ...
Iker's user avatar
  • 1,280
2 votes
1 answer
61 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 ...
The Quantum Physicist's user avatar
2 votes
1 answer
49 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 ...
user6894661's user avatar
1 vote
3 answers
408 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 ...
atesz's user avatar
  • 21
1 vote
0 answers
88 views

Getting error in rust while compiling substrate node-template [closed]

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...
Amit Kumar Yadav's user avatar
0 votes
1 answer
199 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, ...
not 0x12's user avatar
  • 343
1 vote
1 answer
101 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 ...
Jin GuangHao's user avatar
2 votes
1 answer
177 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 ...
yonatan hornstein's user avatar
3 votes
1 answer
146 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 ...
yonatan hornstein's user avatar
3 votes
1 answer
115 views

Can't 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 ...
som3_l0cust's user avatar
3 votes
1 answer
57 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-...
CREESTL's user avatar
  • 474
2 votes
1 answer
95 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 ...
Karanvir Singh's user avatar
1 vote
1 answer
335 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 ...
som3_l0cust's user avatar
4 votes
1 answer
214 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 ...
Squirrel's user avatar
  • 3,759
6 votes
1 answer
254 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 ...
Squirrel's user avatar
  • 3,759
1 vote
0 answers
49 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 ...
Nuke's user avatar
  • 1,822
1 vote
1 answer
112 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("...
user3384741's user avatar
1 vote
1 answer
52 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 ...
jakerumbles's user avatar
0 votes
1 answer
135 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 ...
marethyu's user avatar
  • 207
1 vote
1 answer
326 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....
Russo's user avatar
  • 1,193
5 votes
1 answer
120 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 ...
jpataylor's user avatar
  • 321
4 votes
1 answer
127 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....
Rtsne42's user avatar
  • 379
11 votes
3 answers
557 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, ...
edmassarani's user avatar
7 votes
1 answer
180 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 ...
Ankan's user avatar
  • 325
1 vote
1 answer
89 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 ...
Shubham Gupta's user avatar
9 votes
3 answers
189 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 ...
andresvsm's user avatar
  • 1,104
2 votes
1 answer
712 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 ...
boundless-forest's user avatar
8 votes
1 answer
132 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 ...
drbh's user avatar
  • 83
7 votes
1 answer
141 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. ...
Kapil Yadav's user avatar
3 votes
1 answer
36 views

pallet-mmr-rpc missing impl

this is my service config. this is my rpc config. this is error message.
99kies's user avatar
  • 733
2 votes
1 answer
221 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, ...
Kittywhiskers Van Gogh's user avatar
3 votes
1 answer
274 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
Rong Nguyen's user avatar
3 votes
2 answers
89 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 ...
Kittywhiskers Van Gogh's user avatar
14 votes
2 answers
1k 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 ...
infinitesimallySmart's user avatar
4 votes
2 answers
158 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 ...
infinitesimallySmart's user avatar
10 votes
3 answers
365 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 ...
user16756428's user avatar
9 votes
2 answers
273 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 ...
Russo's user avatar
  • 1,193
7 votes
1 answer
102 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 ...
Rtsne42's user avatar
  • 379
2 votes
2 answers
120 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-...
D.Davirain's user avatar
4 votes
1 answer
203 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 ...
Russo's user avatar
  • 1,193
3 votes
2 answers
41 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(...
Amiya Behera's user avatar
4 votes
1 answer
287 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 ...
Promlert Lovichit'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