sendTransaction v sendAndConfirmTransaction
因此,在我的代码中,我在后端执行以下操作,并想知道应该使用哪个?
const sig = await web3.sendAndConfirmTransaction(connection, createMetadataTx, [mint_authority], {
skipPreflight: false
})
const sig = await connection.sendTransaction(
createMetadataTx,
[mint_authority],
{
skipPreflight: false,
}
);
我猜测 sendAndConfirmTransaction 需要更长的时间,但确认 trx 已被接受进行处理,但不一定最终确定?
我的连接“承诺”对此有何影响?:
const connection = new Connection(tokenType.cluster, "processed");
So in my code I am doing the following in my backend and wondering which I should use?
const sig = await web3.sendAndConfirmTransaction(connection, createMetadataTx, [mint_authority], {
skipPreflight: false
})
const sig = await connection.sendTransaction(
createMetadataTx,
[mint_authority],
{
skipPreflight: false,
}
);
I am guessing that the sendAndConfirmTransaction takes a little longer but confirms that the trx has been accepted for processsing, but not necessarily finalized?
And what bearing does my connection 'commitment' have on this?:
const connection = new Connection(tokenType.cluster, "processed");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sendTransaction
只是广播交易,并不等待它在网络上确认。然后,您可以单独使用confirmTransaction
来检查交易是否已在网络上确认。sendAndConfirmTransaction
执行这两项操作,并且直到交易在网络上得到确认或删除后才会返回。您可以:
sendTransaction
sendAndConfirmTransaction
sendTransaction
just broadcasts the transaction and does not wait for it to confirm on the network. You can then useconfirmTransaction
separately to check it the transaction was confirmed on the network.sendAndConfirmTransaction
does both and doesn't return until the transaction is either confirmed on the network or dropped.You would:
sendTransaction
if you are ok with send and forget or manual confirm latersendAndConfirmTransaction
if you want to know the transaction status before any further processing