英文:
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("Transaction ID: " + transactionId.toString());
The transaction receipt does not have the transaction id and it's only stored in consensus nodes for only 3 minutes.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论