调用web3.sendrawtransaction(signature.serialize())时出错
我想签署来自Phantom Wallet的用户交易,然后通过Web3.js发送交易,但是成功签署了交易后,Web3JS库函数sendrawtransaction()给出控制台中的错误消息
const signedTransaction = await window.solana.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());
await connection.confirmTransaction(signature);
I want to sign a transaction of a user from phantom wallet and then send the transaction through web3.js but after successfully signing the transaction the web3js library function sendRawTransaction() is giving error message in console
const signedTransaction = await window.solana.signTransaction(transaction);
const signature = await connection.sendRawTransaction(signedTransaction.serialize());
await connection.confirmTransaction(signature);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看
sendtransaction
的实现,您会发现它在签名,序列化和发送之前向交易中添加了一个块。如果没有阻止,您将获得该错误blockhash找不到
。因此,相反,您需要执行以下操作:sendtransaction的完整实现
https://github.com/solana-labs/solana/solana/solana/blob/3fcdc45092b969b969b969baeb7273de65969699999998277773666/weectionIf you look at the implementation of
sendTransaction
, you'll see that it's adding a blockhash to the transaction before signing, serializing, and sending. Without a blockhash, you'll get that errorBlockhash not found
. So instead, you need to do something like:Full implementation of
sendTransaction
at https://github.com/solana-labs/solana/blob/3fcdc45092b969baeb7273de6596399d98277366/web3.js/src/connection.ts#L4389