Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7906

Sending transaction that expiry early instead of 150 blocks validity

$
0
0

How do I send transaction which only valid for next X blocks, instead of default 150 blocks / ~ 1 minute (https://solana.com/docs/core/transactions#recent-blockhash).I need the transaction to fail fast, I need X to be in small number, i.e : 10-20 blocks instead of full 150 blocks.

const { lastValidBlockHeight, blockhash } = await connection.getLatestBlockhash({ commitment: "confirmed" });    const messageV0 = new TransactionMessage({        payerKey: payer,        recentBlockhash: blockhash,        instructions,    }).compileToV0Message(); // how do i get the value here which only valid for next X blocks ?    const transaction = new VersionedTransaction(messageV0);    transaction.sign([payerKey]);    const signature = await connection.sendTransaction(transaction);    // wait 1 minute    await connection.confirmTransaction(        {          blockhash: blockhash,          lastValidBlockHeight: lastValidBlockHeight,          signature: signature,        },"confirmed"      );

Viewing all articles
Browse latest Browse all 7906

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>