I want to do this inside a precompile, so it is runtime and I don't have access to std.


1 Answer 1


Yes, you can convert an address in SS58 format into the 32-byte public key. The process of encoding a public key to an SS58 format address is fully reversible since it just implies adding a prefix, a checksum and a bidirectional encoding of the bytes (like in Bitcoin's base-58).

The tool Subkey allows you to get the SS58 address from the public key and viceversa. This is done with the command:

subkey inspect --public < pubkey | address >

Finally, you can do this "manually" with the account transformation tool provided by Subscan. And there are some public tools to do this conversion but they may not be fully tested and maintained.

  • This does not work in the runtime / no-std. Mar 19 at 13:35
  • Good point. I would say the important part here is the first paragraph in my answer. For proper implementation of the encoding function they can check this other answer for guidance and implement their own in the precompile: substrate.stackexchange.com/questions/2311/…
    – Iker
    Mar 20 at 11:26

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