如何在cosmos sdk中将txRaw转换为txHash



我正在使用api Cosmos SDK"https://api.cosmos.network/blocks/9888530"获取1个区块的详细信息

我得到它txRaw:"CpMBCpABChwvY29zbW9zLmJhmsudjFiZXRhMS5Nc2dTZW5kEnAKLWNvc21vczF0NXUwamZnM2xqc2pyaDJtOUN2Q0bnkyaGVhN2VlaHhyemRnZBItY29zb W9zMTNseWxmbHVzYTRwYxRtbDBsamt1ZzRsNjR4NXlsNDYwMzMwa2FlGhAKBXVhdG9tEgcyMDAwMDAwEmkKUgpGCh8vY29z W9zlNyeXB0by5zWNwMwjU2azEuUHViS2V5EiMKIQLqGodLEwWelzPDXpDLKlhlpGtk7ZDSVVR8B8SOSf8YhIECgIIfxjw3iISEwoNCgV1YXRvbRIEMjUwMBCImAuQNksf4cmAZodzcEOwNNlFkK1zxGmE3Rtc2/f3JfIqG9HrbeVJhWjrIWizhmwGCYjhcbjpFpX8vCgGEwAyquwaM=";

如何将txRaw转换为txHash以使用api获取详细信息事务:https://api.cosmos.network/cosmos/tx/v1beta1/txs/8689064A44E7F2D6131ED15D014938EB772FD4DFD4348A71F525578E2895D612谢谢你的帮助!

感谢您的问答。但对我来说,只有toHex返回正确的哈希:

const { sha256 } = require("@cosmjs/crypto")
const { toHex } = require("@cosmjs/encoding")
const txRaw = "<raw>"
const txHash = toHex(sha256(Buffer.from(txRaw,'base64')))
console.log(txHash)

也许它对某人有用。。。

我找到了答案,希望它能帮助到别人,简单的是:

const txHash=sha256(Buffer.from(txRaw,'base64'((

相关内容

  • 没有找到相关文章

最新更新