Questions tagged [rust]
Questions about the Rust programming language, the primary language used in the Substrate ecosystem.
264
questions
5
votes
2
answers
643
views
How do I move my USDC/USDT to statemine?
Hi I heard USDT and USDC is now on statemine. How do I get access to that?
Assuming I have USDT on my ERC20 wallet, how do I get that to a substrate-based chain/parachain?
0
votes
1
answer
27
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 ...
0
votes
0
answers
37
views
How to convert str type to AccountID type? [duplicate]
Personally, while writing the Treasury contract, it was necessary to change the string type to the account ID type. Even if I google how to do it, I can't find a proper solution, so I'm curious what ...
0
votes
1
answer
89
views
How to use code written in `std` in `no_std` during runtime?
I have a piece of code written in std, and it is bypassing/not-included in runtime as it should work but I want to use it in runtime environment, is there a way to use it. As the code written in std ...
0
votes
1
answer
44
views
Compiled code withe #[cfg(feature = "std")] and facing issues while setting up staging environment
I have compiled my code successfully and it is running fine in development mode, when I make the staging environment for the same with 3 nodes the code written inside #[cfg(feature = "std")] ...
0
votes
1
answer
57
views
Problem with converting a solo chain to a parachain in Substrate
I am trying to convert my solo chain to parachain but I am facing some trouble. First, I ran parachain template as well as the relaychain template of Polkadot and it worked fine. Next, I just copied ...
2
votes
3
answers
2k
views
Rust WASM toolchain not installed, please install it! -- Basilisk node
I know that similar questions have been asked before but I am not able to resolve this issue with my setup. I am trying to run a basilisk node but keep running into the errors below.
The error log:
...
3
votes
1
answer
88
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
1
answer
51
views
How to read storage when using ValueQuery
I have the below code, if you see I am storing the ContractSender struct as OptionQuery.
Later on, I am trying to read the data from the Struct, but was not able to.
#[pallet::storage]
#[pallet::...
6
votes
1
answer
60
views
Is it possible to extend Prometheus metrics in Substrate?
Is it possible to register custom metrics to be exported via Prometheus? Specifically, we would like to write values specific to the runtime - e.g. TVL, average throughput, etc..
1
vote
1
answer
141
views
How to call payable methods with the polkadot API?
I want to call a payable method using the polkadot API.
if the method would not be payable it would look like this:
const { gasRequired, storageDeposit, result, output } = await contract.query
...
1
vote
1
answer
102
views
Fails to run polkadot on macbook m1 chip with error: <jemalloc>: Error allocating TSD
The polkadot project builds with no problems on my m1 chip macbook, but when I try to execute the executatble, I get the following error
❯ ./target/release/polkadot --chain=polkadot
<jemalloc>: ...
1
vote
1
answer
35
views
Constructor not found when testing smart contract
I am implementing a project using the directory structure proposed by openbrush.
The contract compiles without a problem, but when it comes to testing I run
into the following error:
error[E0599]: no ...
1
vote
1
answer
128
views
How to set up an project utilizing openbrush?
I am currently trying to setup a project where I intend to have multiple contracts
call on each other. Since I am using the openbrush standard (mostly to implement
an NFT using PSP34) I thought it ...
1
vote
0
answers
59
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 ...
0
votes
2
answers
84
views
Smoldot Documentation
How to run smoldot repository code and connect with our substrate based chain or substrate node ?
On official documentation of smoldot on github is not in detail .Please answer here complete way to ...
1
vote
2
answers
904
views
the trait `std::default::Default` is not implemented for AccountId [duplicate]
I have an issue. I wold like to store a struct using AccountId as key:
#[derive(Clone, Copy, Encode, Decode, RuntimeDebug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub struct Contract<Origin, ...
0
votes
1
answer
32
views
Substrate node template: ./scripts/docker_run.sh command does not work
I am trying to execute the above command but have the following issue:
[+] Running 7/7
⠿ dev Pulled ...
1
vote
1
answer
82
views
Substrate Node to light Client
How can I make substrate node light as light client ? If we want to build a light client can it be possible to make changes in substrate node and make it a light client.
5
votes
1
answer
268
views
Build a docker file/image for my new pallet
I am using substrate-node-template and recently I added a new pallet.
Now I need to build a docker file because I would like to send it for testing.
Any information?
Thank you.
1
vote
1
answer
128
views
Examples of Substrate Benchmarking
I am looking to learn to benchmark. Except for the official documentation, I did not find much information/examples.
Can you please help me with examples/articles?
Thanks!
0
votes
3
answers
291
views
Mac m1 substrate node template can't be build
I get this issue when I try to build the substrate-node-template
error: failed to run custom build command for `prost-build v0.10.4`
Caused by:
process didn't exit successfully: `/Users/elioprifti/...
0
votes
1
answer
26
views
Can we use rust unstable features in substrate?
I found there is almost no rust unstable feature usage inside substrate, is that a coincidence, code of conduct, or for some specific reasons?
0
votes
1
answer
29
views
Which files to change in smoldot to design light client according to our need.?
I want to design a light weight blockchain that is interoperable. Being light weight, it will be able to take part in consensus and create new nodes without doing complex computations and wasting ...
0
votes
1
answer
54
views
frame-benchmarking version conflict
Below is the cargo.toml file of one of my pallet.
[package]
name = "escrow"
version = "3.0.0"
edition = "2018"
authors = ['Substrate DevHub <https://github.com/...
3
votes
1
answer
65
views
Why using value and value reference as parameter in functions of StorageValue and StorageMap are both OK?
In my coding, I find that I can use a value or a value's reference as parameter in function StorageValue::put(). The same case is in function StorageMap::insert(). In my view, I can not input a value ...
1
vote
1
answer
32
views
Substrate upgrade to 0.9.26: the trait bound `Event: From<pallet_transaction_payment::Event<Runtime>>` is not satisfied
When trying to upgrade to Substrate v 0.9.26, I see this error:
the trait bound `Event: From<pallet_transaction_payment::Event<Runtime>>` is not satisfied
In my config I have the ...
1
vote
1
answer
116
views
How to store date on storage?
I would like to store a date and later on compare it to the current date.
How can I do it?
Thanks
0
votes
1
answer
46
views
How to import sp_core::Pair?
In my last question, I asked about how to generate key pair in substrate.But it seems that it is hard to do this.So I have to make a conclusion that I can't generate key pair in substrate sadly. But ...
3
votes
0
answers
52
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 ...
1
vote
1
answer
166
views
Get Metadata inside custom rpc call
Hello I am creating custom rpc call, I need metadata to be able to decode extrinsics call inside my calls.
But I don't know how to get substrate metadata inside my rpc call?
0
votes
1
answer
99
views
Persist Event on Error- Ink Contracts
Is there a way to persist event from contract even in case of error? Currently the deposited event seems to disappear when error occurs in contract.
1
vote
1
answer
110
views
Why getter function don't return Result type?
I'm using #[pallet::getter(fn get_balance)] for my StorageMap to generate a getter function, but it returns pure u64 instead of Result type. What is the way to handle missing key cases then?
#[...
2
votes
1
answer
78
views
How to get Rust contract methods to output/print when running on substrate-contracts-node?
I have tried following instructions from:
https://rustrepo.com/repo/paritytech-substrate-contracts-node
and
https://ink.substrate.io/faq/#how-do-i-print-something-to-the-console-from-the-runtime
My ...
2
votes
1
answer
265
views
Call ink contract using rust
I'm a developer who wants to call the ink contract's function from the outside. I already know that ink contract supports cross-contract. But what I want to do is call the function using subxt or ...
0
votes
1
answer
104
views
Is there a EIP712 pendant in rust?
I am looking for an implementation of the EIP712 standard in rust.
Like the psp22 openbrush standard which is more or less the equivalent
to the erc20 standard.
1
vote
1
answer
47
views
How to change the caller of a method when testing smart contracts in rust?
I am implementing a smart contract according to the psp34 openbrush standard.
Now I want to do some testing.
I want to mint a token and then use it in some methods.
Some of the methods of my smart ...
0
votes
1
answer
62
views
How to use an Error define in one pallet in another pallet
I have a substrate pallet A and it has following Errors Defined
#[pallet::error]
pub enum Error<T> {
/// Not a coffee
InvalidCoffee,
}
trait implementation in Pallet ...
4
votes
1
answer
77
views
usage of `#[pallet::constant]` vs `const associated item`
I can have config of my pallet in two different ways:
trait Config: frame_system::Config {
// *--snip
#[pallet::constant]
SomeConstant: Get<u32>,
const ANOTHER_CONSTANT: u32,
}
...
5
votes
1
answer
357
views
Is possible to extract the runtime version from WASM file?
Is possible to extract the runtime version from the WASM file?
Sometimes, I want to verify the WASM file's content locally.
1
vote
1
answer
361
views
Simple runtime call in Rust
I am building a somewhat generic client for Substrate-based chains in Rust using the subxt crate. To learn about runtime calls, my goal was to call the core.version runtime API directly using the RPC ...
0
votes
1
answer
257
views
How to implement Custom Data Structure for ink! storage?
I want to create custom data structure. I'm a newbie with Rust and Ink! and can't get how to implement my data structure to use it in Mapping.
I have such a structure:
pub struct TokenInfo {
data: ...
2
votes
1
answer
41
views
How to get the Hash's length?
I'm trying to get the length of hash. Currently, I tried to make use of len_bytes() like in this docs. But I encountered an error like the below image.
Please help to solve this.! Thanks in advanced.
2
votes
1
answer
124
views
How to upgrade Frontier to use a specific Substrate version
The Substrate team(https://github.com/paritytech/substrate/) produces releases like polkadot-v0.9.25 every a few weeks,
and my team needs to upgrade our parachain to follow those Substrate versions.
...
3
votes
1
answer
94
views
Adding support for p256 keys and signatures (secp256r1)
Is it possible to add support for other cryptographic algorithms, or are we only allowed to use the implemented ones?
The implemented ones are sr25519, ed25519, ecdsa(secp256k1, not secp256r1).
I ...
1
vote
2
answers
246
views
How can I deploy & interact with contract on substrate using rust, not polkadot js?
I'm currently trying to deploy & interact with my contract using rust, but I can't find any methods or examples about this. (I've searched paritytech's github) Is there any way to deploy & ...
1
vote
1
answer
398
views
"Rust WASM toolchain not installed" with v0.9.25
I recently upgraded a fork of the Node Template to v0.9.25 and now I am getting an error about the Wasm toolchain not being installed. Per the official Substrate documentation, the failing build is ...
1
vote
1
answer
71
views
Calling Error messages when cross contract calling in ink
I want to call Error messages from different contract I am calling in ink! using
the '?' operator.
However it gives me the following Error:
`?` couldn't convert the error to `contract::Error`
--...
1
vote
1
answer
364
views
Is there a way to use the 256-bit integer type in ink?
In the ink! documentation I found the Keccak256 hash, which gives back a 256-bit hash.
However I can not find a 256-bit integer in the ink! documentation.
If I want to cast from the 32 bytes to an ...
1
vote
1
answer
93
views
How to remove "Verifying "build-script-build" pop up
I am running macOS and every so often I get the following pop up:
I believe this is the Rust Analyzer on VS Code but I am not 100% sure.
I cannot get rid of it, only minimize it.
Has anyone else run ...