Skip to main content

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
108 views

Division operation in `u128` results false value

In my node, Balance type is u128. I have following variable let per_block = 100_000_000_000_000_000_u128; let total = 50_000_000_000_000_000_000_000_u128; let ratio = per_block.checked_div(total); ...
0 votes
0 answers
11 views

When i tried to add the third well known node, it shows is added but it's not?

I am following the Authorize Specific Nodes and i tried to add the third known node, but i couldn't. It said it was added but it seems it did not even though i tried to added again it said it is ...
0 votes
1 answer
29 views

Substrate Build failures

As someone new to rust and substrate, I have noticed that besides the simple "build a blockchain" tutorial most fail during the build process. To avoid that I even tried grabbing specific ...
1 vote
1 answer
37 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: ...
0 votes
2 answers
48 views

Build Error with `tikv-jemalloc-sys v0.5.4+5.3.0-patched` in Substrate Node Template

I am encountering a build error when running cargo build --release on a Substrate Node Template project. Here is the error message: error: failed to run custom build command for `tikv-jemalloc-sys v0....
0 votes
1 answer
41 views

Compilation Error with Substrate on Rust Nightly: #![feature] May Not Be Used on the Stable Release Channel

I'm working on a Substrate-based blockchain project and encountering a compilation error when trying to build my node runtime. The error indicates that nightly features are being used while the stable ...
0 votes
0 answers
16 views

How to get the ink! examples working

I have been banging my head in over the last couple of days trying to understand Rust and ink! I would really like to start writing smart contracts in the substrate ecosystem but I can't even get the ...
2 votes
1 answer
140 views

How to fix "module group is private" error when using frame-support-procedural-tools v3.0.0?

I'm trying to use orml-tokens in my Substrate project and encountered the following error: error[E0603]: module `group` is private --> /home/kianoush/.cargo/registry/src/github.com-...
0 votes
1 answer
26 views

the trait `Deserialize<'_>` is not implemented for `T`, which is required by `HackerNewsInfo<T>: Deserialize<'_>`

I am trying to write offchain worker and read json file. But I faced this error. ganesholi@Ganeshs-MacBook-Air Node_Hackathon_Apr2024 % cargo build --release warning: virtual workspace defaulting to `...
0 votes
1 answer
14 views

Trouble Registering Events in Substrate Tutorial's Frontend Transaction: Need Assistance

I'm a beginner following the Substrate tutorial from here. After successfully compiling both the Substrate node and frontend, I've encountered an issue. Problem: When I open the frontend and attempt ...
1 vote
2 answers
226 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() { ...
0 votes
1 answer
31 views

How to increment Uniques Pallet T::ItemId

I have following substrate pallet implementation to split an Item and create new Items #[pallet::call_index(26)] #[pallet::weight(T::WeightInfo::split())] pub fn split( ...
2 votes
1 answer
155 views

How can I decode this error message {"ok":{"flags":["Revert"],"data":"0x000110"}}?

I'm using polkadotjs to call my ink! smart contracts and I seem to be having trouble with calls that require parameters. For the call below I am getting the revert flag {"ok":{"flags&...
0 votes
1 answer
22 views

How to declare runtime api?

I have a runtime constant declared in a pallet like this: /// How much space there is on the network. #[pallet::constant] type TotalSpacePledged: Get<u128>; Source code ...
0 votes
0 answers
96 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-...
2 votes
1 answer
32 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 ...
0 votes
1 answer
33 views

Multiple test mock runtimes with slightly different configs based off common base?

We have some custom pallet unit tests that use multiple mock runtimes that are configured slightly differently. The problem is that when we have to make changes to the runtime, we have to apply those ...
0 votes
0 answers
51 views

Bittensor Subtensor Chain

Does anyone know how to run a public subtensor node and synchronize with Bittensor network on nakamoto instead of the current finney ? There are some nodes currently running on nakamoto chain. I am ...
0 votes
2 answers
36 views

Is it it possible to change native token decimals of chain that is already running?

A blockchain I am working on enabled Frontier recently but since EVM chains' native tokens got 18 decimals by default and the chain's native token decimals are set to 12 we need to do decimals ...
4 votes
1 answer
24 views

error[E0282]: type annotations needed --> /libp2p-noise-0.32.0/src/protocol/x25519.rs:221:45

While running this project https://github.com/jimmychu0807/substrate-offchain-worker-demo I'm geting this error: error[E0282]: type annotations needed --> /libp2p-noise-0.32.0/src/protocol/x25519....
3 votes
1 answer
93 views

Cargo-contract forcibly calls nightly-2022-06-30 regardless of specified toolchain

I am experiencing an issue when using cargo-contract (version 1.5.1) to build a project (command: cargo +nightly contract build). The specified toolchain is not being recognized, and the process is ...
0 votes
1 answer
28 views

How can I access a value obtained at runtime in primitives npos elections?

I want to change the weight/score of targets on the basis of values got during runtime, in my research I found the score of a target is being calculated in primitives/npos-elections/phragmen.rs in fn ...
2 votes
1 answer
46 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] ...
2 votes
3 answers
110 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()...
0 votes
1 answer
39 views

Build fails when trying to create workspace from selected pallets and primitives

I want to put some pallets and primitive code in a workspace. Here is my code https://github.com/zeitgeistpm/external However this does not build, neither workspace builds nor individual components. ...
0 votes
1 answer
55 views

How to deploy smart contract in ink which constructor takes value in params

I have written an erc20 smart contract in ink(Rust). The contract has been compiled successfully. But I got an error while deploying my smart contract. Basically, the contract constructor takes ...
0 votes
2 answers
69 views

Build error on substrate-node-template with missing target

I am getting this error: Rust WASM toolchain not installed, please install it! Further error information: ------------------------------------------------------------ Compiling wasm-test v1....
1 vote
0 answers
26 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 ...
0 votes
0 answers
21 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 ...
3 votes
1 answer
322 views

build failed with substrate chain on rocksdb in linux

I followed this tutorial https://docs.substrate.io/tutorials/get-started/build-local-blockchain/. I got the below error when run cargo build --release. How can I fix it? cargo build -v --release ...
1 vote
2 answers
108 views

"the wasm*-unknown-unknown targets are not supported by default" -error while compiling ink smart contract

I am attempting to build a smart contract for an imaginary burger shop. But I keep getting this error when I run the build command. The test compiles, and cargo check compiles successfully too. Here ...
2 votes
1 answer
114 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 ...
0 votes
1 answer
32 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 ...
0 votes
0 answers
24 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 ...
0 votes
1 answer
45 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. ...
1 vote
0 answers
29 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 ...
2 votes
1 answer
52 views

Error when Adding weight related configurations

I'm in the process of configuring weights for a pallet pub struct GymWeight<T>(PhantomData<T>); impl<T: frame_system::Config> WeightInfo for GymWeight<T> { fn ...
1 vote
1 answer
111 views

Unable to calculate logarithm of a number error method log10 ln

When I tried to get a logarithm of a number I'm getting following errors in Substrate, how to fix this? 437 | let cc = f32::log10(4 as f32); | ^^^^^ function or ...
0 votes
2 answers
95 views

Failed to build substrate-node-template using Macbook pro M1 pro

I'm unable to build substrate-node-template using my Macbook pro M1 Pro laptop. I updated cmake and followed the official guide I also tried with the flag --locked Here is the error log: error: failed ...
3 votes
1 answer
169 views

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

As the title suggest, I'm trying to call PSP22 token contract and read balanceOf() function, but I get error that I'm passing a too big of a input (27 instead of 8) When I initializing the token it ...
1 vote
0 answers
43 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]: ...
1 vote
1 answer
32 views

Calculation gives the wrong result

After doing a simple calculation in rust ink! 4.0 smart contract, the result is incorrect and doesn't match the expected result. Here is the simple formula: let a0_balance_mul:U256 = U256::from(...
1 vote
2 answers
3k views

error: linking with `cc` failed: exit status: 1 (Mac m1)

Not able to build a project because of this issue: error: linking with `cc` failed: exit status: 1 | = note: "cc" "-arch" "arm64" "/var/folders/5w/...
3 votes
1 answer
164 views

Code coverage setup in Substrate

At my current company we are using Substrate for our developments, we have an automated setup with test and whatnot. We are now evaulating our options regarding code coverage. We are thinking of a ...
0 votes
1 answer
243 views

Build error on substrate-node-template

I'm met with an error when running this command cargo build --release on substrate-note-template. I haven't really done anything other than git clone to my directory and executed the cargo build ...
0 votes
2 answers
123 views

How to set timestamp in benchmarks?

Is it possible to use std for benchmarks? If not, how can I get timestamps in a benchmark? I tried using this but it didn't compile: #[cfg(feature = "runtime-benchmarks")] extern crate std;...
1 vote
0 answers
34 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 ...
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 ...
1 vote
1 answer
35 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....
3 votes
0 answers
35 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, ...

1
2 3 4 5 6