如何在使用以下代码转账 Hbar 后获取交易 ID?

huangapple go评论61阅读模式
英文:

How do I get the transaction id after I transfer Hbar using the following code?

问题

以下是翻译好的部分:

"但是,收据中没有交易ID。我如何获取交易ID?"

英文:

I am following this tutorial and writing code to send hbar from my account to another account.

<https://docs.hedera.com/hedera/getting-started/transfer-hbar>

const sendHbar = await new TransferTransaction()
     .addHbarTransfer(myAccountId, Hbar.fromTinybars(-1000)) //Sending account
     .addHbarTransfer(newAccountId, Hbar.fromTinybars(1000)) //Receiving account
     .execute(client);

let receipt = await sendHbar.getReceipt(client);

However, there is no transaction id in the receipt. How do I get the transaction ID?

答案1

得分: 0

交易 ID 是由 SDK 本身生成的。要获取 sendHbar 交易的交易 ID,您可以在交易对象上使用 getTransactionId 方法。以下是一个示例:

const transactionId = sendHbar.transactionId; 
console.log("Transaction ID: " + transactionId.toString());

交易收据不包含交易 ID,它仅在共识节点中存储了 3 分钟。

英文:

The transaction id is generated from the SDK itself. To get the transaction ID of the sendHbar transaction, you can use the getTransactionId method on the transaction object. Here's an example:

const transactionId = sendHbar.transactionId; 
console.log(&quot;Transaction ID: &quot; + transactionId.toString());

The transaction receipt does not have the transaction id and it's only stored in consensus nodes for only 3 minutes.

huangapple
  • 本文由 发表于 2023年4月13日 23:12:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007092.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定