英文:
Is there a way to extend the transaction validity over 180 seconds?
问题
当前,我的策略涉及创建一个事务对象(例如TransferTransaction),该对象配置为满足必要的要求,包括指定所需的签名。接下来,我冻结事务并添加任何本地签名,并对其进行序列化,以允许用户添加自己的签名并查询事务属性。
一旦所有签名都已添加到事务中,我执行它。但是,如果在transactionValidDuration内未添加签名,网络会返回“TRANSACTION_EXPIRED”。
const transferTransaction = new TransferTransaction()
.addHbarTransfer(senderAccountId, new Hbar(1))
.addHbarTransfer(receiverAccountId, new Hbar(-1))
.setNodeAccountIds(nodeId);
// 冻结事务,防止进一步修改
const transaction = await transferTransaction.freezeWith(client);
const signature1 = privateKeySigner1.signTransaction(transaction);
// 签名者二使用他们的私钥对事务进行签名
const signature2 = privateKeySigner2.signTransaction(transaction);
// 签名者三使用他们的私钥对事务进行签名
const signature3 = privateKeySigner3.signTransaction(transaction);
const signedTransaction = transaction.addSignature(publicKey1, signature1).addSignature(publicKey2, signature2).addSignature(publicKey3, signature3);
我想知道是否有一种被接受的模式来收集签名,允许比默认的180秒更长的时间框架。
英文:
Currently, my strategy involves creating a Transaction object (e.g., TransferTransaction) that is configured to meet the necessary requirements, including specifying the required signatures. Next, I freeze the transaction and add any local signatures, and serialize it to allow users to add their own signatures and interrogate the transaction properties.
Once all signatures have been added to the transaction, I execute it. However, if the signatures are not added within the transactionValidDuration, the network returns TRANSACTION_EXPIRED
.
const transferTransaction = new TransferTransaction()
.addHbarTransfer(senderAccountId, new Hbar(1))
.addHbarTransfer(receiverAccountId, new Hbar(-1))
.setNodeAccountIds(nodeId);
//Freeze the transaction from further modifications
const transaction = await transferTransaction.freezeWith(client);
const signature1 = privateKeySigner1.signTransaction(transaction);
//Signer two signs the transaction with their private key
const signature2 = privateKeySigner2.signTransaction(transaction);
//Signer three signs the transaction with their private key
const signature3 = privateKeySigner3.signTransaction(transaction);
const signedTransaction = transaction.addSignature(publicKey1, signature1).addSignature(publicKey2, signature2).addSignature(publicKey3, signature3);
I am curious if there is an accepted pattern for gathering signatures that allows for a longer time frame than the default 180 seconds.
答案1
得分: 0
交易的有效期限为180秒,不能超过此时限。我知道收集多个签名需要超过180秒,因此我们有一个定时交易。定时交易允许您向网络提交交易,它将等待执行,直到获得所有必需的签名。目前,定时交易的最大有效时间为30分钟。然而,有一个提案在HIP-423中概述,旨在延长定时交易的有效期,您可能需要查看。
您还可以查看此处有关调度交易的示例代码:https://docs.hedera.com/hedera/tutorials/more-tutorials/schedule-your-first-transaction。
英文:
The validity of a transaction is limited to 180 seconds and cannot be extended beyond that. I know that collecting multiple signatures will require more than 180 seconds, which is why we have a scheduled transaction. A scheduled transaction allows you to submit a transaction to the network, and it will wait to be executed until it has all the required signatures. Currently, the maximum valid time for a scheduled transaction is 30 minutes. However, there is a proposal to extend the validity of scheduled transactions outlined in HIP-423, which you may want to review.
You can also take a look at the example code for scheduling transactions here: https://docs.hedera.com/hedera/tutorials/more-tutorials/schedule-your-first-transaction.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论