Skip to main content
disclaimer on other confirmation methods
Source Link
Joey Meere
  • 1.6k
  • 2
  • 17

From the question, I assume you're confirming transactions with connection.confirmTransaction(signature, "confirmed)

Try using this instead:

const block = await connection.getLatestBlockhash("confirmed");
const result = await connection.confirmTransaction(
    {
      signature,
      ...block,
    },
    "confirmed",
);

const error = result.value.err;
if (error) {
    throw Error(error.toString());
}

This will confirm based on block height rather than a 30sec threshold. Additionally, if you aren't already, consider prepending a priority fee to your transactions:

const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: <microlamport fee>,
});

EDIT: There are better ways to do confirmations that are a bit more involved, but those are out of the scope of this question

From the question, I assume you're confirming transactions with connection.confirmTransaction(signature, "confirmed)

Try using this instead:

const block = await connection.getLatestBlockhash("confirmed");
const result = await connection.confirmTransaction(
    {
      signature,
      ...block,
    },
    "confirmed",
);

const error = result.value.err;
if (error) {
    throw Error(error.toString());
}

This will confirm based on block height rather than a 30sec threshold. Additionally, if you aren't already, consider prepending a priority fee to your transactions:

const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: <microlamport fee>,
});

From the question, I assume you're confirming transactions with connection.confirmTransaction(signature, "confirmed)

Try using this instead:

const block = await connection.getLatestBlockhash("confirmed");
const result = await connection.confirmTransaction(
    {
      signature,
      ...block,
    },
    "confirmed",
);

const error = result.value.err;
if (error) {
    throw Error(error.toString());
}

This will confirm based on block height rather than a 30sec threshold. Additionally, if you aren't already, consider prepending a priority fee to your transactions:

const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: <microlamport fee>,
});

EDIT: There are better ways to do confirmations that are a bit more involved, but those are out of the scope of this question

Source Link
Joey Meere
  • 1.6k
  • 2
  • 17

From the question, I assume you're confirming transactions with connection.confirmTransaction(signature, "confirmed)

Try using this instead:

const block = await connection.getLatestBlockhash("confirmed");
const result = await connection.confirmTransaction(
    {
      signature,
      ...block,
    },
    "confirmed",
);

const error = result.value.err;
if (error) {
    throw Error(error.toString());
}

This will confirm based on block height rather than a 30sec threshold. Additionally, if you aren't already, consider prepending a priority fee to your transactions:

const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
    microLamports: <microlamport fee>,
});