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);
If 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