When I am trying to send SOL using sendTransaction function it gives me below error
WalletSendTransactionError: failed to send transaction: Transaction simulation failed: Blockhash not found
Code:
const sendSol = async (event: React.ChangeEvent<HTMLFormElement>) => {
event.preventDefault()
if (!connection || !publicKey) { return }
const transaction = new Web3.Transaction();
transaction.add(
Web3.SystemProgram.transfer({
fromPubkey: publicKey,
toPubkey: new Web3.PublicKey(creatorsAddress),
lamports: event.target.amount.value * Web3.LAMPORTS_PER_SOL
}),
);
const latestBlockhash = await connection.getLatestBlockhash();
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
transaction.recentBlockhash = latestBlockhash.blockhash;
sendTransaction(transaction, connection).then((sig) => {
setTxSig(sig)
});
}