如何将 Hedera 账户 ID 别名(十六进制)转换为 Hedera 账户 ID 别名(仅限字符)?

问题描述 投票:0回答:1

我想知道如何将帐户 ID 别名(十六进制)转换为帐户 ID 别名(仅限字符)。比如从

0.0.302a300506032b657003210030a028ee7fd716c438de818a8831ed2235d0f85e430ab036dbfac173eb50aef9
格式到
0.0.HIQQEXWKW53RKN4W6XXC4Q232SYNZ3SZANVZZSUME5B5PRGXL663UAQA.
格式,Hedera SDK中有没有函数可以实现这个功能?

javascript sdk hedera-hashgraph
1个回答
2
投票

您可以使用镜像节点 API 请求检索此信息:

    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];

公钥使用

account.publickey
查询参数传入。

accountInfo
对象包含您正在寻找的字段(以及其他几个字段)。


其他信息

“很长账号ID”其实就是“长账号ID”, 在HIP-32 - 自动帐户创建中定义。

请注意,这不应该与中定义的任何帐户别名格式混淆 HIP-583 - 扩展 CryptoCreate 和 CryptoTransfer 交易中的别名支持

© www.soinside.com 2019 - 2024. All rights reserved.