I'm trying to submit a transaction from a frontend application (React, @solana/web3.js
), but every now and then when I try to submit a transaction, it fails with this error message:
err: SendTransactionError: failed to send transaction: Minimum context slot has not been reached
at Connection.sendEncodedTransaction (...)
I can try clicking again and it usually works on the second try, but is there a way to reliably avoid this error? My transaction submission code looks like this:
try {
const {
context: { slot: minContextSlot },
value: { blockhash, lastValidBlockHeight },
} = await connection.getLatestBlockhashAndContext("finalized");
const signature = await connection.sendRawTransaction(transaction, {
minContextSlot,
skipPreflight: true,
});
const confirmation = await connection.confirmTransaction({
signature: signature,
blockhash,
lastValidBlockHeight,
minContextSlot,
});
...
} catch (error) {
...
}