Questions tagged [rust]
Questions about the Rust programming language, the primary language used in the Substrate ecosystem.
38
questions with no upvoted or accepted answers
4
votes
1
answer
26
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....
4
votes
1
answer
100
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 ...
3
votes
0
answers
36
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, ...
3
votes
0
answers
107
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\&...
3
votes
1
answer
327
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
...
3
votes
0
answers
62
views
NPOS not working after adding the EVM to node config in substrate
I have implemented the NPOS with EVM blockchain using the substrate.
NPOS working fine but after adding EVM to Genesis config in node the NPOS is not working and the staking election failed.
Smart ...
2
votes
3
answers
112
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()...
2
votes
1
answer
53
views
What is the use of Get trait in tracks of referenda pallet?
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
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 ...
2
votes
1
answer
160
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&...
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 ...
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 ...
1
vote
0
answers
44
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
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
2
answers
249
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() {
...
1
vote
0
answers
22
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)
...
1
vote
0
answers
27
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
39
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: ...
1
vote
0
answers
24
views
BoundedBTreeMap error with Debug trait
Consider the following snippet
#[weight = 100_000_000] //TODO: update weights
pub fn test(
_origin,
_outputs: frame_support::BoundedBTreeSet<JoyBalanceOf<...
1
vote
0
answers
55
views
Call a smart contract method from the offchain worker
As the title is descriptive I would like to call a method on a Sample contract deployed to runtime evm, from the off-chain worker.
For example:
Contract Sample {
Public five=5;
}
Call Sample.five() ...
1
vote
0
answers
64
views
Problem to run docker image
I'm trying to run the image pulled from dockerhub: https://hub.docker.com/repository/docker/gertdjali/escrow but doesn't work.
I ran the image locally by terminal './scripts/docker_run.sh' as ...
1
vote
0
answers
61
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 ...
0
votes
0
answers
10
views
calldata in the substrate contract ui
how can I get the calldata of the function in the wasm contract in the substrate contract UI ?
I was trying to mimic the behaviour of the upgradeToAndCall() of the solidity,but in that they are ...
0
votes
0
answers
17
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
0
answers
18
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 ...
0
votes
1
answer
30
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 ...
0
votes
1
answer
53
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
56
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
1
answer
34
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
22
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 ...
0
votes
0
answers
27
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
0
answers
196
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 {
...
0
votes
0
answers
248
views
Getting rust-analyzer error while running a substrate based chain
My problem
Running cargo build does not give any error in terminal but rust-analyzer of Visual studio code gives me 85 errors and 8 warnings.
I followed the installation guide from the substrate docs. ...
0
votes
0
answers
38
views
Bags-list pallet test case not running
I am using the polkadot version 0.9.36, I run test cases of all the pallets in the frame by using the cargo test command, every pallet test case is working fine but when I run the bags-list pallet ...
0
votes
0
answers
47
views
Running substrate-node-template throws macOS memory error
I am using substrate-node-template. I don't have any issue building the substrate-node-template in release mode, and when I try to run it the first time it works fine, but if I stop and try to run it ...
0
votes
1
answer
34
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
1
answer
42
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
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 ...