Questions tagged [rust]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
23 views

how to know about token implementation?

I have a questions about Tokens in polkadot ecosystem , If I am on parachain and this parachain A uses a token from another parachain B , if this token implements on_transfer hook does this hook will ...
castle_chain's user avatar
2 votes
3 answers
93 views

Error Bad origin on custom XCM integration

I am building custom XCM pallet. While executing specific call: The destination is of ParaId type. match send_xcm::<T::XcmSender>( (Parent, Junction::Parachain(destination.into()...
Dudo's user avatar
  • 21
0 votes
0 answers
19 views

is it necessary to download all the dependencies and the full target file to compile and build any contract?

due to I have limited internet in my country , I can not download the full building files after I wrote the contract and need to only see if there are any errors and need to run the tests . so if I ...
castle_chain's user avatar
0 votes
1 answer
25 views

facing unconstrained type parameter issue

I'm using fresh node template and trying to implement below code: #[pallet::storage] pub type Author<T: Config> = StorageValue<_, sr25519::Public, OptionQuery>; pub struct ...
Deepak Chaudhary's user avatar
0 votes
0 answers
18 views

When i built my custom pallet i got this error

#! [cfg_attr(not(feature = "std"), no_std)] // Re-export pallet items so that they can be accessed from the crate namespace. pub use pallet::*; #[frame_support::pallet] pub mod pallet { use ...
Preethi M's user avatar
0 votes
1 answer
42 views

error[E0576]: cannot find associated type `RuntimeCall` in trait `pallet_nfts::Config`?

"I'm developing a pallet called xnft for cross-chain NFT transfers. To achieve this, I have to utilize functions from the Frame NFT pallet and incorporate RuntimeCall in its configuration. ...
Ipsa Gupta's user avatar
1 vote
0 answers
26 views

How to implement XCM into Mock.rs for tests in Pallet?

How to implement XCM into Morck.rs for tests in Pallet? I use XCM in my Lib.rs calls. I have to implement the following: type XcmSender = XcmRouter; type RuntimeOrigin = RuntimeOrigin; type ...
Dudo's user avatar
  • 33
1 vote
0 answers
34 views

Polkadot-v1.0.0: sc-network is failing to compile

When specifying sc-network as a dependency: sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } I get a compile error: error[E0433]: ...
Thomas Braun's user avatar
1 vote
0 answers
28 views

I am having issues with implementing swap fees on transfer for DEX

Below is my lib.rs file for the token contract and it uses the Cardinal Cryptography PSP22 sample at https://github.com/Cardinal-Cryptography/PSP22 I am trying to implement swap for the transfer taxes ...
Edinyanga Ottoho's user avatar
1 vote
2 answers
103 views

How to print / output from within async tokio test

I am writing a new test and when I run this code, the println's do not output in the terminal. #[tokio::test] async fn can_fetch_child_keys() { if std::option_env!("TEST_WS").is_none() { ...
Bruno's user avatar
  • 8,260
3 votes
0 answers
29 views

How to use enum with associated value(s) in ink smart contract

I have an ink smart contract message that takes an enum as argument. The code is shown below; #[derive(Encode, Decode)] #[cfg_attr( feature = "std", derive(Debug, PartialEq, Eq, ...
Ahmad Bolaji's user avatar
1 vote
1 answer
34 views

Issues with Cross Contracts calls

I am trying to compile my Rust (ink!) source code for an AMM DEX on Substrate (Aleph Zero), but this is the error I am receiving from the logs: The following are the files: [azero_trading_pair/cargo....
Edinyanga Ottoho's user avatar
2 votes
1 answer
43 views

What is the use of Get trait here?

In the referenda pallet, type Tracks uses two trait, Get and TracksInfo substrate/frame/referenda/src/lib.rs /// Information concerning the different referendum tracks. #[pallet::constant] ...
Amiya Behera's user avatar
1 vote
0 answers
19 views

How to Modify static buffer size for my ink smart contract to Resolving 'OutputBufferTooSmall' Error for Larger Vectors in ink smart contract

I'm facing an 'OutputBufferTooSmall' error in my [Language/Framework] code when working with larger vectors. I suspect this is related to the maximum allowed input/output sizes. I need guidance on how ...
UPENDRA SINGH's user avatar
1 vote
0 answers
19 views

"ContractTrapped" Error even with successful cross-contract call

let result_call = ink::env::call::build_call::<Environment>() .call(self.escrow_address) .gas_limit(0) .transferred_value(0) ...
Parth's user avatar
  • 11
0 votes
1 answer
42 views

How to handle all the characters in Vec<u8>?

I am using vec to storing the string data on the chain. So when any user passing few special character it just convert it into the binary data and storing that binary data on the chain. Which we ...
Pankaj's user avatar
  • 2,051
2 votes
2 answers
92 views

How to Retrieve Value by Single Key from StorageDoubleMap in Substrate?

I'm developing a Substrate-based blockchain and using StorageDoubleMap to store label details. The StorageDoubleMap is defined as follows: #[pallet::storage] #[pallet::unbounded] #[pallet::getter(fn ...
Mr Coder's user avatar
  • 893
1 vote
0 answers
25 views

How to change the gas cost in ink! e2e tests

I want to be able to adjust the gas cost used in specific ink! end-to-end (e2e) tests, but my attempts to do so have consistently resulted in a return value of zero when using the weight_to_fee ...
Brian Ramirez's user avatar
1 vote
1 answer
49 views

Trait Bound f64: scale_info::TypeInfo Is Not Satisfied

I'm working on a Substrate-based blockchain project and I've run into an issue related to type information and encoding. Specifically, I'm trying to use an f64 field within a struct that also uses ...
Mr Coder's user avatar
  • 893
1 vote
1 answer
64 views

How to get typed keys when querying a storage map via subxt

The example here https://github.com/paritytech/subxt/blob/master/subxt/examples/storage_iterating.rs use subxt::{OnlineClient, PolkadotConfig}; #[subxt::subxt(runtime_metadata_path = "../...
Damian's user avatar
  • 13
2 votes
1 answer
47 views

Is there a simple MHT (Merkel Hash Tree) in-place algorithm?

I want to write a low memory usage algorithm to calculate MHT
Jiuqu's user avatar
  • 23
2 votes
1 answer
78 views

MultiAddress to Address String

I'm trying to retrieve the author's address as a string, and I've successfully obtained the MultiAddress using the following code: let validator_address = if let Some(author_multi_address) = ...
Yeou's user avatar
  • 229
0 votes
1 answer
67 views

how to remove Mapping storage when tuple is used as input

Lets assume we have an ink! smart contract On a vanilla Mapping alpha: Mapping<[u8;32], Astruct> we can use self.alpha.remove(&somehash) My question is this: if we have the following ...
Sokrates's user avatar
  • 421
1 vote
1 answer
62 views

Calculate Session/Epoch time remaining

I've seen some websites display the estimated time remaining for the current session/epoch. Is there a Rust call for this? Is there a sample of that code?
CrackerJack9's user avatar
0 votes
0 answers
121 views

Rust Compile Error: Unresolved imports crate::pallet, crate::types::Types::Config

I am working on a Rust project where I have multiple modules. I'm facing an issue with unresolved imports when I try to compile my code. Here's the relevant code structure: types.rs pub mod Types { ...
Mr Coder's user avatar
  • 893
2 votes
1 answer
128 views

Is it permissible to retrieve the value of a private field within a struct from one pallet while working with another pallet?

I am developing a cross-chain NFT transfer pallet that involves transferring both item metadata and collection metadata. To accomplish this, I need to access the data field within the ItemMetadata ...
Ipsa Gupta's user avatar
0 votes
1 answer
36 views

Deriving Contract Reference from `ink::trait_definition`

Is it possible to create a Contract Reference to perform a Cross-Contract call from ink::trait_definition? If it is, how can I do so? If it is not, why it is not possible? It seems strange that we can ...
Yrefef's user avatar
  • 75
1 vote
1 answer
40 views

Get the block timestamp using subxt

I am using subxt to get the block details, including the block number, hash, parent hash, timestamp, events and the extrinsics. I am able to find most details, except the timestamp. Is there a way to ...
Yeou's user avatar
  • 229
1 vote
1 answer
35 views

Need help in Ink e2e tests

I need help with that code. Can anyone pls help me out ?? mod p{ #[ink(storage)] pub struct Foobar { /// Stores a single `bool` value on the storage. value: ...
Shivam Varshney's user avatar
2 votes
1 answer
158 views

panicked at 'assertion failed: `(left == right)`

I am having a setup of relay chain and two parachains are connected to it, I was running some test cases and during that i encounter an error thread 'test::...
Ipsa Gupta's user avatar
1 vote
1 answer
35 views

Substrate node template build errors and rustup version

Once in a while, doing a rustup update will break the substrate node template, the challenge then becomes to identify the rustup release compatible with the latest node-template and downgrade. is this ...
Kazunobu Ndong's user avatar
3 votes
1 answer
77 views

Incompatibility between subxt_signer and subxt

https://github.com/paritytech/subxt/blob/master/subxt/examples/tx_basic.rs I want to call a function in my substrate pallet. I am using the substrate-node-template subxt subxt_signer use subxt::{...
Haider's user avatar
  • 71
2 votes
1 answer
107 views

Problem with timestamps in governance platform

I have governance platform written in ink!, where I can create poll with pollId, number of options, and with poll_start_time and poll_end_time. And this is fine. So when poll is started I can't call ...
jvn's user avatar
  • 55
1 vote
1 answer
40 views

How to get and modify cross-chain asset in contract?

I am preparing to create a smart-contract on Astar using ink! programming language. The contract's main logic involves modifying the cross-chain asset USDT on the statemint chain. After going through ...
jeffery xu's user avatar
1 vote
2 answers
105 views

Reading contract value returns null

Facing an issue while trying to query for a value in my contract. The value keeps getting retuned as null with an error. However, it works fine on substrate Contracts UI Front end Dapp : const ...
0xD1x0n's user avatar
  • 119
0 votes
1 answer
82 views

Scalecodec: How can I get the equivalent of Decode in Python, instead of DecodeAll?

When using the Python script: timestamp = ScaleDecoder.get_decoder_class('Timestamp', ScaleBytes(timestamp_bytes_array)).decode() it seems that the decoder expects the size of the array to be exactly ...
The Quantum Physicist's user avatar
1 vote
3 answers
67 views

How to call PSP22::approve function from Frontend

Any guidance on how to call my psp22 approve function from the front end ? This is currently how I'm doing it but it doesn't seem to give increased allowance (although its successful) : import { ...
0xD1x0n's user avatar
  • 119
0 votes
1 answer
79 views

Encountered incremental compilation error

I have encountered following error from time to time while compiling substrate-node-template error: internal compiler error: encountered incremental compilation error with mir_built(76e5305fbe3bf3e0-...
metricaez's user avatar
0 votes
1 answer
21 views

error: Invalid generic declaration, trait is defined with instance but generic use none

I want to make a storage for the pallet but I'm getting this error /// The target parachains to ping. #[pallet::storage] pub type Targets<T:Config> = StorageValue< _, BoundedVec&...
Arunjot Singh's user avatar
1 vote
1 answer
32 views

New to Rust: Seeking Clarification on RuntimeEvent Type Resolution in Substrate-Parachain-Template

I'm a newcomer to Rust and have been working with the Substrate-Parachain-Template. So far, I've managed to get everything to compile and run without issue, which is a good start. However, I've come ...
AnonDao's user avatar
  • 23
0 votes
3 answers
169 views

Get SS58 Address from public key

I have my hex public key, how can I convert it to an SS58 Address? I have found the snippet to do it using PolkadotJS here: How to convert Public key (hex) to SS58 Address in JavaScript / Polkadot-JS? ...
Alex Bean's user avatar
  • 5,629
3 votes
2 answers
180 views

How node and runtime are connected?

When we run a substrate client cargo run -- --dev we run a substrate-node. The business logic is defined on the pallets composed by construct_runtime! inside the runtime. So which part of the node is ...
Abishek Bashyal's user avatar
3 votes
0 answers
96 views

Not enough data to fill buffer

When running an API function using rust, we get this error: GenericError { reason: "Failed to get unsigned proposals: FailedToDecodeReturnValue { function: \"DKGApi_get_unsigned_proposals\&...
Thomas Braun's user avatar
4 votes
2 answers
56 views

WebAssembly runtime file into ValidationCode

I have a CLI tool that gets a WebAssembly runtime file: let validation_code_content = fs::read_to_string(path_validation_code) .expect("Should have been able to read the validation code ...
Alex Bean's user avatar
  • 5,629
3 votes
1 answer
90 views

Persistent overuse of system resources by rust-analyzer

After limiting the number jobs in order to handle the amount of resources used by rust-analyzer it keeps using all cores so my computer ends up hanged out: In addition, I've noticed that several ...
magecnion's user avatar
  • 200
2 votes
1 answer
45 views

Why does compiling substrate require nightly toolchain?

rustup target add wasm32-unknown-unknown --toolchain nightly Why can't the stable toolchain be used to compile, what I beleive is the runtime to WASM? Why is nightly needed?
b0zero's user avatar
  • 533
3 votes
2 answers
79 views

implement trait on a type

I want to implement pallet-assets on a type which is: pub trait Config<I: 'static = ()>: Config { type RuntimeEvent: From<Event<Self, I>> + IsType<<Self as Config>::...
Braden Watts's user avatar
3 votes
2 answers
197 views

Specialization impl does not specialize any associated items

I'm fairly new to Rust and ink! itself. I'm trying to compile and build an extremely basic PSP22 Contract. I get the following error when I compile & build: (running cargo +nightly contract build) ...
0xD1x0n's user avatar
  • 119
2 votes
1 answer
110 views

Error while trying to run e2e rust ink! tests

I'm getting the following error while trying to run e2e rust ink! smart contracts tests: #![feature(min_specialization)] using the following command: cargo test --features e2e-tests I'm using this ...
yonatan hornstein's user avatar
2 votes
1 answer
97 views

How to Implement MaxEncodedLen Trait for Structs Containing Vec<u8> in Rust

i'm trying to create a blockchain runtime module using Substrate. I have defined a few data structures with the #[derive(MaxEncodedLen)] attribute, but I'm running into a problem when trying to ...
Mr Coder's user avatar
  • 893

1
2 3 4 5 6