Skip to main content
edited tags
Link
Nuke
  • 1.9k
  • 1
  • 7
  • 27
Source Link
Nathan
  • 454
  • 2
  • 10

Convert any address to accountId (in hex)

How can i convert an address of the form "5DTNtGF2DmZ7QwGxg6n1xWzF6cEokNyNre7mUqpVuozrLxu3" to hex using polkadotjs packages?

Here is the context:

I have multiples array of datas, containing address: balance. I have to make interactions between these data (like searching the balance of the specific address). The problem is that, between array, the format is different (addresses start by 3, sometime by 5, sometimes are in hex...) so i cannot compare anything as the format is different.

So i'd like to convert everything back to a hex account id, where everything will correspond.

I'v found a way to change the prefix, decode into array of 32 int, but i couldnt find a way to convert to hex...