Questions tagged [rust]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
17 views

MultiAddress to Address String

I am trying to obtain the author address as a string. I have obtained the MultiAdress, as the following code:- let validator_address = if let Some(author_multi_address) = multi_address { if let ...
Yeou's user avatar
  • 157
0 votes
0 answers
38 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
  • 407
1 vote
1 answer
40 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
23 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
  • 795
2 votes
1 answer
87 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
29 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
  • 63
0 votes
1 answer
14 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
  • 157
1 vote
1 answer
25 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
37 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
21 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
2 votes
2 answers
40 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::{...
MF H's user avatar
  • 51
2 votes
1 answer
101 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
  • 45
1 vote
1 answer
26 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
77 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
0 answers
30 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
45 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
36 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
20 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
26 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
  • 13
0 votes
3 answers
70 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
  • 4,839
3 votes
2 answers
153 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
80 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
52 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
  • 4,839
3 votes
1 answer
51 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
  • 136
2 votes
1 answer
37 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
  • 502
3 votes
2 answers
68 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
160 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
79 views

Error while trying to run e2e rust ink! tests

Im 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 Im using the ...
yonatan hornstein's user avatar
2 votes
1 answer
91 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
  • 795
5 votes
2 answers
123 views

"ERROR: Loading of original wasm failed" after upgrading rustup

I'm getting the following error when compiling a rust ink! 4.0; ERROR: Loading of original wasm failed It's started happening to me after I rustup update and now my rustc versions are: stable-...
yonatan hornstein's user avatar
3 votes
1 answer
99 views

Subxt - Catch Extrinsic Error

I am doing sudo call using this example Making sudo call using subxt: let found_event = api .tx() .sign_and_submit_then_watch_default(&tx, &bob) .await? ....
Alex Bean's user avatar
  • 4,839
4 votes
1 answer
15 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....
S Miss's user avatar
  • 41
4 votes
0 answers
98 views

How to solve this Failed to compact generated WASM binary.: Error(UnknownOpcode(192))

For one assignment I have run the command cargo build --release so that I can build the pallet. After that I was getting the error After that according to this- Error Building Substrate contract Node(...
Nakul Agrawal's user avatar
1 vote
1 answer
25 views

Calculation gives the wrong result

After doing a simple calculation in rust ink! 4.0 smart contract, the result is incorrect and doesnt match the expected result. Here is the simple formula: let a0_balance_mul:U256 = U256::from(...
yonatan hornstein's user avatar
4 votes
1 answer
32 views

Pallet generate store is deprecated how to avoid this warning and compile the code?

I am getting error in #[pallet::generate_store(pub(super) trait Store)] which is showing deprecated warning due to which I could not compile my custom pallet is there any solution
Parth Kohli's user avatar
1 vote
1 answer
45 views

What is distinction between self (lowercase) and Self (uppercase) In Rust?

I am trying to fetch caller address in ink smart contract to apply some checks. let owner = self._check_token_exists(&id)?; let caller = Self::env().caller(); I am confused which one i should use ...
UPENDRA SINGH's user avatar
5 votes
2 answers
62 views

Trying to implement U256 in rust ink! 4.0

I've implemented use primitive_types::U256 and now I'm trying to return a U256 int as a result from one of my functions, but I'm getting the following error: the trait TypeInfo is not implemented for ...
yonatan hornstein's user avatar
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 ...
UPENDRA SINGH's user avatar
1 vote
2 answers
51 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 ...
HunnyPawt's user avatar
1 vote
1 answer
58 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-...
Arunjot Singh's user avatar
3 votes
0 answers
46 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 ...
Yasu Yasu's user avatar
3 votes
1 answer
29 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 ...
Bernardo Rodrigues's user avatar
1 vote
1 answer
47 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/...
Arunjot Singh's user avatar
2 votes
1 answer
94 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&...
Jordan Greenberg's user avatar
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))...
Muhammad Zaryab Rafique's user avatar
1 vote
1 answer
48 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 ...
Jordan Greenberg's user avatar
0 votes
1 answer
33 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 ...
Chetan Ukani's user avatar
1 vote
3 answers
112 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 ...
UPENDRA SINGH's user avatar
4 votes
1 answer
65 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 ...
Simson's user avatar
  • 929
4 votes
2 answers
83 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::...
Pierina Ponce's user avatar

1
2 3 4 5 6