Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I convert an Hedera Account ID Alias (hexadecimal) into an Hedera Account ID Alias (chacracters only)?

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?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading