Skip to main content

Questions tagged [no-std]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
2 answers
82 views

Alternative to BlakeTwo256 for WASM Compatibility in a no_std Environment in Rust

I'm developing a Rust script that I need to convert to WebAssembly (WASM). In this script, I'm using the BlakeTwo256 hasher, which is imported from the sp_runtime crate. However, I'm unable to compile ...
Deepak Chaudhary's user avatar
4 votes
1 answer
54 views

Is there a way to use a crate that depends on the `std` in substrate OCW?

from what I've learned so far, the OCW is designed specifically for executing heavy and time-consuming computations outside of the runtime. As the OCW is not a part of runtime/wasm, I guess the OCW ...
Yahor Tsaryk's user avatar
1 vote
1 answer
178 views

Why is serde always std-gated in substrate?

I regularly see serde implemented for various structs across the substrate ecosystem, usually in the single-liner form below. Why is that gated behind the std feature? In serde's documentation, it's ...
Nate Armstrong's user avatar
0 votes
1 answer
67 views

Bech32 encode/decode library for no_std to convert bytes32 into string address in runtime pallet?

I want to convert bytes into string address. I have only two options because of Junction limitation: bytes32 or bytes20. pub enum Junction { ... AccountId32 { network: Option<NetworkId>, ...
rust.dev's user avatar
  • 539
2 votes
2 answers
107 views

Calling std-based host function from a pallet

Based on: Use std only rust library to extend substrate runtime interface? How to understand [runtime-interface] and `Externalities`? I understand that I should be able to: have a crate that is not ...
pmikolajczyk41's user avatar
4 votes
1 answer
118 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
  • 1,275
2 votes
1 answer
41 views

Why not implement the sp_std::fmt::Debug for AccountId32 in non-std

https://github.com/paritytech/substrate/blob/d443f148ce0aa6a51798b86c6b3ae54113786f94/primitives/core/src/crypto.rs#L584-L595 Why not implement the sp_std::fmt::Debug for AccountId32 in non-std like ...
zjb0807's user avatar
  • 21
5 votes
0 answers
204 views

How to check if a pallet can be compiled to no-std/WASM?

How to check if a pallet can be compiled to no-std/WASM? I ran: cargo build --no-default-features --target wasm32-unknown-unknown But this didn't work. IIUC, we need some ENV to build the pallet to ...
aurexav's user avatar
  • 11.2k
1 vote
1 answer
115 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 ...
boundless-forest's user avatar
1 vote
1 answer
40 views

Using Valico JSON validator in my pallet [closed]

Currently I have problem that Valico is using std based packages like serde and serde_json. Is there any workaround to use this package? UPDATE1: I managed to fork repo and fix some dependencies but ...
Brano Hozza's user avatar
0 votes
0 answers
53 views

How to TRACE "duplicated lang item in crate std: ..."

I have an error of duplicated std, I know there is a lot of questions with the same problem, that's why I'm asking how to search for the problem. I basically have an error of this form (I'm trying to ...
Nathan's user avatar
  • 454
0 votes
1 answer
44 views

fail to use a no_std friendly dependence in smart contract

I try to use barebones-x509 which is no_std friendly to parse x509 certificate. But encounter the mistake. Will you have some advice? error: duplicate lang item in crate `std` (which `barebones_x509` ...
dayday2019's user avatar
0 votes
2 answers
130 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;...
Robert La Ferla's user avatar
0 votes
1 answer
62 views

Use std only rust library to extend substrate runtime interface?

I have some rust libraries and they have don't have a no_std implementation. Can I use runtime interface to call those libraries?
TaiZe Wang's user avatar
3 votes
2 answers
75 views

Get results of some std operations in benchmarks

We faced a situation the other day where we needed some result of std operations inside of our benchmarks. Specifically, we were looking to generate key pairs and signatures from types given by ...
Justin Frevert's user avatar
2 votes
1 answer
2k views

error: `#[panic_handler]` function required, but not found

I'm trying to add Substrate to my project and am encountering this error when trying to compile. Do I need to set this explicitly somewhere in my runtime? I see there is an implementation in sp_io but ...
bingo_boingo_bungus's user avatar
0 votes
1 answer
128 views

app_crypto!(sr25519, KEY_TYPE): cannot find trait `TryFrom` in this scope

I am building an ocw demo, the code is from https://github.com/paritytech/substrate/blob/master/frame/examples/offchain-worker/src/lib.rs, when using polkadot-v0.9.25 version, it appears got this ...
Bart Yang's user avatar
1 vote
1 answer
30 views

AssemblyScript Contracts with Javascript Standard Library

I am trying to implement a non-Rust contract using WASM.. Can anyone provide an example, please, of a small contract which returns the balance of an account, completely written in TypeScript / ...
Smagula's user avatar
  • 11
0 votes
1 answer
804 views

duplicate lang item in crate `std` (which `my_crate` depends on): `panic_impl`

I have this hierarchy in my substrate parachain project: my_parachain/ ├── ... ├── runtime folder └── runtime-common folder Cargo.lock Cargo.toml The above runtime-common has some constants and types ...
Russo's user avatar
  • 1,207
0 votes
1 answer
166 views

How can I read JSON files in substrate

I am trying to modify the kitties pallet(https://docs.substrate.io/tutorials/v3/kitties/pt1/) in order to read some json data from an already existing file. So, I need to read the contents of the file ...
John Stephan's user avatar
2 votes
1 answer
131 views

Pallet Fails to Build Because of `std` Macros

I am currently facing this Error: Using rustc version: rustc 1.62.0-nightly (e85edd9a8 2022-04-28) Compiling frame-support v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=...
CREESTL's user avatar
  • 484
1 vote
2 answers
75 views

How to execute an ELF binary after a successful transaction

I am working on figuring out an efficient way to run an ELF binary after successful transaction. I also want to pass arguments along the execution. Example: /bin/ping 1.1.1.1 OCW might be a solution, ...
six's user avatar
  • 13
2 votes
2 answers
559 views

How to enable `std` features in pallets?

I'm trying to implement simple PoW for my node. After debugging all other stuff I've encountered the problem where finality-grandpa and storage do not get compiled because standard library macros are (...
CREESTL's user avatar
  • 484
11 votes
2 answers
186 views

What's the best way to compute square root in Substrate?

I'm working on a quadratic voting function, and I'm trying to use a function like square root. There is no square root function in sp that I could find. What is the best way to do this?
Jake Hemmerle's user avatar
2 votes
2 answers
54 views

Trying to implement Substrate client on IoT, any suggestions?

I'm trying to implement a Substrate client on IoT, to send a basic extrinsic that stores as an example, a key-value. This code needs to run on ARM or ESP32 kinds of chips. Are there any suggestions on ...
lucgerrits's user avatar