I am wondering how I can convert an Account ID alias (hexadecimal) into an Account ID alias (characters only). For example, from the format 0.0.302a300506032b657003210030a028ee7fd716c438de818a8831ed2235d0f85e430ab036dbfac173eb50aef9
to the format 0.0.HIQQEXWKW53RKN4W6XXC4Q232SYNZ3SZANVZZSUME5B5PRGXL663UAQA.
Is there any function in the Hedera SDK that can accomplish this?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
You can retrieve this information using a Mirror Node API request:
The public key is passed in using the
account.publickey
query parameter.The
accountInfo
objects contain the field that you are looking for (and several others).
Additional info
The "very long account ID" is actually a "long account ID",
which is defined in HIP-32 – Auto Account Creation.
Note that this should not be confused with any of the acount alias formats defined in
HIP-583 – Expand alias support in CryptoCreate & CryptoTransfer Transactions.
Another way to do this, without invoking the Mirror Node APIs,
is to perform the required IETF RFC 4648
base32url
conversion locally.To do this, you will need the
rfc4648
npm package.This process is described in HIP-32.