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 AccountId32
or [u8;32]
When running in rich environment, it is easy to convert from ss58 format to AccountId32
using:
use sp_core::{crypto::AccountId32, sp_std};
let a:AccountId32 = sp_std::str::FromStr::from_str(&s);
But checking the source code in sp-core-20.0.0/src/crypto.rs
I can see the FromStr
trait is guarded by a feature flag #[cfg(feature = "std")]
and defined only when compiled in std.
It would of course be possible for me to clone and duplicate this code for core
but is there a better way to run this conversion in a no_std
environment?
Edit: There is a similar question Is there any way to convert an ss58 address to the 32 bytes pubkey? but the answers is all about running in a shell which is not what I'm asking for