I am using the following function in my pallet to convert a string into a public key

        fn split_publickey_from_input(input: &Vec<u8>) -> T::Public {
            let input_string = sp_std::str::from_utf8(input).unwrap();
            let input_vec: Vec<&str> = input_string.split(":").collect();
            let pub_key = sp_core::sr25519::Public::from_str(input_vec[2]).unwrap();

Unfortunately this works well in the pallet but when i try to build the node with cargo build --release i face this error below

let pub_key = sp_core::sr25519::Public::from_str(did_vec[2]).unwrap();
      |                                 ^^^^^^^^ function or associated item not found in `Public`

How can i resolve this error? An explanation of what's going wrong is highly appreciated

1 Answer 1


It's std only. You can't use this in your pallet.


#[cfg(feature = "std")]
impl std::str::FromStr for Public {
    type Err = crate::crypto::PublicError;

    fn from_str(s: &str) -> Result<Self, Self::Err> {

And check this: Is there any way to convert an &str into an AccountId inside a substrate pallet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.