Questions tagged [rust]
Questions about the Rust programming language, the primary language used in the Substrate ecosystem.
264
questions
1
vote
1
answer
45
views
Why we use empty struct named as key of particular lib name in mapping while using it in storage of openbrush libraries
When you go through the openbrush smart contract library. You will notice they are using upgradeable smart contract storage and while defining storage they are using some empty struct as key of ...
1
vote
2
answers
65
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 ...
1
vote
1
answer
63
views
unresolved import `amiquip`
I've added new amiquip dependency in the cargo.toml
[package]
name = "sender"
version = "0.1.0"
edition = "2021"
[package.metadata.docs.rs]
targets = ["x86_64-...
3
votes
0
answers
55
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
1
answer
34
views
Prevent unused imports from bloating up runtime wasm
I recently wrote a pallet that uses a (non-substrate) Rust crate as a dependency.
This crate conveniently supports no-std and Wasm, but it is also quite extensive and there's a lot of code that my ...
1
vote
1
answer
67
views
the trait bound `Vec<u8>: EncodeLike<u32>` is not satisfied
I was making a function to store the some data in the pallet.
#[pallet::storage]
#[pallet::getter(fn number)]
// Learn more about declaring storage items:
// https://docs.substrate.io/main-docs/build/...
2
votes
1
answer
111
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&...
2
votes
0
answers
58
views
Failed to compact generated WASM binary in substrate standalone chain [duplicate]
I'm building the substrate standalone chain with this cargo build --release command and facing the issue:
thread 'main' panicked at 'Failed to compact generated WASM binary.: Error(UnknownOpcode(192))...
1
vote
1
answer
50
views
Creator NFT Royalties on substrate-based blockchains possible?
Coming over from the Ethereum ecosystem and haven't been able to find much information about integrating creator royalties into ERC721 contracts using rust or ink!. I know on Ethereum, the large ...
0
votes
1
answer
43
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 ...
1
vote
3
answers
113
views
Unable to deploy the open-brush contracts build using toolchain nightly-2023-02-07 on substrate node
As you can see in following link . I was not able to build contract using latest rust nighly ( rustc 1.70.0-nightly (17c116721 2023-03-29)) toolchain.
ERROR: Loading of original wasm failed
I got the ...
4
votes
1
answer
76
views
How to parse an ss58 address in no_std rust
In another question
How do I work with SS58 encoded addresses? the same question was addressed, this is however about how to do it without the std lib.
How to convert an ss58 stored in a String to an ...
5
votes
2
answers
103
views
Problem with Vec using ink
I'm trying to make some changes to the Flipper contract, trying to use a vector like the documentation say's it should be imported:
#[ink::contract]
pub mod flipper_plus {
use ink::storage::...
2
votes
1
answer
88
views
Error when building libsecp256k1 for Rust
I am trying to use the libsecp256k1 library in a no-std environment and I get the following error when building the contract:
[wasm-validator error in module] unexpected true: memory max >= ...
2
votes
1
answer
84
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-...
2
votes
1
answer
227
views
execution failed: execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed. TransactionPaymentApi_query_info
We are currently depositing KSM tokens to our parachain using the following code:
kusamaApi.tx.xcmPallet.limitedReserveTransferAssets(params_here)
When executing the transaction, the KSM tokens are ...
3
votes
1
answer
75
views
Chatbot Trained on Substrate-based Chains and Repositories for General Reference and Help [closed]
I'd like to propose an idea for creating a general reference and help tool utilizing a chatbot trained on data from Substrate-based chains (e.g., Polkadot, Kusama, Parachains) and their associated ...
0
votes
0
answers
189
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. ...
1
vote
2
answers
303
views
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
Below is my block of code where I am implementing this trait Config. I am not sure what I am doing wrong here I keep getting error "the type parameter T is not constrained by the impl trait, self ...
10
votes
4
answers
1k
views
ERROR: Loading of original wasm failed
I having some trouble running the Flipper example from the Ink! webpage.
The cargo contract build outputs the following error log:
ERROR: Loading of original wasm failed
Caused by:
0: Loading of ...
5
votes
2
answers
117
views
Logging best practice for pallet extrinsics
What is the best practice for logging in pallets? Is there any overhead leaving them in at a debug/trace level? Or should we never use them outside of development?
e.g.
log::debug!("")
1
vote
1
answer
117
views
why the subxt can not decode metadata
Here is test demo, but always fail to run.
Cargo.toml
[dependencies]
yew = { version = "0.20.0", features = ["csr"] }
gloo = "0.8.0"
wasm-bindgen-futures = "0.4.32&...
2
votes
1
answer
100
views
How to use subxt in yew.rs front-end app
Here is test demo, but always fail to run.
Cargo.toml
[dependencies]
yew = { version = "0.20.0", features = ["csr"] }
gloo = "0.8.0"
wasm-bindgen-futures = "0.4.32&...
1
vote
1
answer
62
views
Why `features = ["std"]` is not necessary in the `[dev-dependencies]` some crates like `sp-io`?
We often use some basic substrate crates such as sp-core, and sp-io while doing pallet tests. In general, those dependencies are put under [dev-dependencies]. But I have an issue with whether we ...
0
votes
1
answer
42
views
How to enable the teleportation for genesis hash in the parity-bridges
How to write the genesis hash in the teleportation to enable the communication of two chains through bridge.By adding the genesis hash it will be easier for the one chain to reach another chain. ...
0
votes
0
answers
37
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 ...
2
votes
2
answers
66
views
substrate node-template how to add `total_insuance` with some accounts initial supply
I am using susbstrate node-template, I am trying to create my own native token d-coin with xxxxx amount of total supply, I am using auro consensus, I was able to add some properties to genesis state, ...
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 ...
4
votes
2
answers
87
views
How do i pass a `Vec<u8>` as argument to a contracts function, using the command line(cargo contract)
When using cargo contract to call contracts, in all the examples i've seen, its either been AccountId or boolean or integers(u & i). I need to pass a Vec<u8> to my contract function. I've ...
3
votes
2
answers
159
views
expected struct `Weight`, found integer
I was making parity-bridges-common compatible to the stable version of polkadot-v0.9.32. I'm getting the error:
expected struct Weight , found integer.
Because earlier the weight in the frame-support ...
0
votes
1
answer
28
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 ...
1
vote
1
answer
280
views
Substrate node-template Compiling sp-externalities error: cannot find macro `thread_local` in this scope
When I am trying to build substrate node-template, cargo build below error occurs. How to solve this issue.
system : Apple M1 Pro
OSX : Ventura 13.2.1
rustup show
installed toolchains
-----------------...
0
votes
1
answer
82
views
Getting error after runtime upgrade
I am trying to upgrade the version of substrate on my running blockchain from version v0.9.25 to v0.9.36, everything is fine but after runtime upgrade my terminal shows this [869] 🏊♂️ Running ...
3
votes
2
answers
116
views
Can’t get logging to work in a custom pallet when running unit tests
I can’t get logging to work in a custom pallet when running unit tests:
RUST_LOG=runtime=debug cargo test --features rococo-local -- --nocapture
log::debug!("") doesn’t work and println!() ...
1
vote
1
answer
156
views
the trait `std::clone::Clone` is not implemented for `Nominations<T>`
I was making a new event in the function nominate of Staking pallet which is going to show when the nominator is going to be added. But i facing one issue
#[pallet::call_index(5)]
#[pallet::weight(...
2
votes
1
answer
31
views
Error generating Raw Chainspec from Plain Chainspec in Substrate
I am trying to generate raw chain spec from plain chain spec, but it won't let me:
✗ ./target/release/node-template build-spec --chain plain-local-chainspec.json --raw > chain-spec.json
Error: ...
0
votes
1
answer
36
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.
...
1
vote
1
answer
88
views
How does `derivative_account_id` create an `AccountId`?
In the Utility pallet there is a function:
/// Derive a derivative account ID from the owner account and the sub-account index.
pub fn derivative_account_id(who: T::AccountId, index: u16) -> T::...
1
vote
2
answers
71
views
Cross pallet methods calling not working
I want to update staking_ledger from a custom pallet for migration of data from one chain to another, using method pallet_staking::Pallet::<T>::update_ledger but i am getting error that ...
4
votes
1
answer
120
views
Is there any way to access the accountid inside the offchain worker?
I am coding a pallet in which I need to know who I am inside a offchain worker to check if I should send a transaction or not. Right now I have access to the account in the send_signed_transaction ...
1
vote
1
answer
57
views
How to use smoldot in rust application?
I can find only javascript interfaces and documentation to interact with it, but nothing regarding rust?
Feels a bit weird to use js library for rust application in rust application. Neither subxt ...
1
vote
1
answer
623
views
Error in asset_eq! - binary operation `==` cannot be applied to type
For my pallet I have defined a StorageMap in the storage that stores a tuple.
#[pallet::storage]
pub(super) type NameOf<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, (Nickname<...
2
votes
2
answers
203
views
Is there any way to convert an &str into an AccountId inside a substrate pallet?
Is there any way to convert an &str into an AccountId inside a substrate pallet?
I need this because a evm precompile is interactive with the pallet, and its sending the address (its already in ...
0
votes
1
answer
54
views
How do you perform a state query in a unit test?
In a custom Substrate pallet unit test, I need to get a list of governance proposals using the chain state. I have used Polkadot JS to query state before but not from within a Substrate unit test in ...
1
vote
1
answer
517
views
`let...else` statements are unstable [closed]
trying to update to the latest polkadot-v0.9.37
when i cargo check i get:
Checking sc-executor-wasmi v0.10.0-dev (https://github.com/paritytech/substrate?branch=polkadot-v0.9.37#946507ba)
...
1
vote
1
answer
76
views
Is there a way to call a cryptographic library from inside the ink! contract?
This is one such link containing some examples of ink! contracts from parity's repo : https://github.com/paritytech/ink-examples/blob/main/rand-extension/lib.rs
Is there a way to call a custom ...
0
votes
2
answers
52
views
Can I use Blake2 128 to store sensitive data?
I would like to store some sensitive data and because the node would be public I am worried that if can be reserved.
What do you suggest to store sensitive data(passwords) in blockchain?
2
votes
2
answers
112
views
cannot multiply `&&EdwardsBasepointTable` by `&Scalar`
I'm trying to build a custom pallet using the substrate-node-template, and when I run cargo check on the pallet, it's all good. But when I run cargo check or cargo build --release on the whole node, ...
2
votes
1
answer
112
views
I have a problem with getting the return type of Balance from "ink::env::call::build_call" and the contract keeps panicking when called
let selector: [u8; 4] = [0xbd, 0x77, 0x15, 0xef];
let amount_out = build_call::<DefaultEnvironment>()
.call_type(Call::new().callee(self.liquidity_pool_address))
.exec_input(
...
1
vote
1
answer
30
views
Is there a way to set a fixed Local Peer ID in a Substrate blockchain?
I am currently working with a Substrate blockchain and I was wondering if there is a way to set a fixed Local Peer ID, instead of it being generated dynamically every time the node starts up. I have ...