async function makePayment() {
try {
setProcessing(true);
let success = false;
while (!success) {
const transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: publicKey!,
toPubkey: new PublicKey("BEwvWR2TjmkgPJ8kCBFkqHNRGDuVWH4AyvnFCiFaEcAs"),
lamports: 22348000, // 0.022348 sol // 3.10 usd // 260 inr
})
);
const { context: { slot: minContextSlot }, value: { blockhash, lastValidBlockHeight } } = await connection.getLatestBlockhashAndContext();
const signature = await sendTransaction(transaction, connection, { minContextSlot });
try {
await connection.confirmTransaction({ signature, blockhash, lastValidBlockHeight });
success = true;
console.log("Payment succeeded with signature:", signature);
setTxSignature(signature);
alert("Payment success. Now add task!");
} catch (confirmationError) {
console.warn("Confirmation failed, retrying with a new blockhash...", confirmationError);
}
}
} catch (err) {
setProcessing(false);
console.error("Payment failed:", err);
alert("Payment failed. Please try again.");
} finally {
setProcessing(false);
}
}
After initiating the transaction of the mentioned lamports, it is getting success but confirmation is giving following error:
upload.tsx:63 Confirmation failed, retrying with a new blockhash… TransactionExpiredBlockheightExceededError: Signature 64UmRfE4D5y1T9gGi2aV4m2Y13gqn3WgUHhfRmRrcyCT4b7xYfnanvZrnDntjuz4eqjQMEchQHcwFnWfNnCP3Gf2 has expired: block height exceeded.
at Connection.confirmTransactionUsingBlockHeightExceedanceStrategy (connection.ts:4059:15)
at async Connection.confirmTransaction (connection.ts:3870:14)
at async makePayment (upload.tsx:57:21)
I tried changing the factor of verifying transaction to only signature and it is showing the strategy is deprecated