1

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

}
1

2 Answers 2

1

I have solved this issue by changing network to devnet. Previously, I was on mainnet-beta

0

I see you are providing the recent blockhash in your code so the issue shouldn't be that and it could probably be with your network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.