I am new to Sol web3 dev. I am trying to get pending transactions of a wallet. When I try to get the block, it fails with error "SolanaJSONRPCError: failed to get confirmed block: Block not available for slot " Could somebody help me? Here is my code snippet and it fails at getBlock or getConfirmedBlock methods.

const connection = new Connection('https://api.mainnet-beta.solana.com'); // Use the appropriate network

async function copyPendingTrades() { // Subscribe to new blocks const subscription = connection.onSlotChange(async (slotInfo) => { // Fetch all transactions in the latest block const blockhash = await connection.getRecentBlockhash(); const confirmedTransactions = await connection.getConfirmedBlock(slotInfo.slot); const unconfirmedTransactions = await connection.getBlock(slotInfo.slot);

// Extract unconfirmed transactions
const pendingTransactions = unconfirmedTransactions.transactions.filter(
  (tx) => !confirmedTransactions.transactions.some((confirmedTx) => confirmedTx.transaction.signature === tx.transaction.signature)

1 Answer 1


There's a couple of things to clarify here.

The error Block not available for slot is happening because you're querying the block with getBlock before it's been confirmed. Only confirmed blocks are available with getBlock.

In fact, it is impossible to query information about unconfirmed transactions through getBlock. If you want to check on the confirmation status of a transaction, you need to know its signature and then use connection.confirmTransaction with that signature to see if it's been confirmed.

There's no concept of "pending transactions" that can be queried, unless you run some external service that holds this information in a database.

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.