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?
You can retrieve this information using a Mirror Node API request:
const accountInfoFetchUrl = `https://testnet.mirrornode.hedera.com/api/v1/accounts?account.publickey=${publicKey}&balance=false&limit=1&order=desc`;
const accountInfoResponse = await fetch(accountInfoFetchUrl);
const accountInfo = (await accountInfo.json).accounts[0];
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.