Return timing of connection.confirmTransaction

In solana/web3.js, there is a method called ‘confirmTransaction’ and it returns a slot number.

I think this slot number is the block number that my transaction is included.

But, when this method returns it to me?

For example, suppose my transaction is included in block B at time T. Then which one is right ?

  1. As soon as my transaction is included in block B at time T. It returns block number B to me at time T + (network delay).
  2. It waits for more blocks to be confirmed. For example, it waits for more N blocks to be connected after block B and then returns block number B to me, at time T + (blocktime * N) approximately + (network delay).

The reason why I ask this questions is that It seems to be needed quite long time to confirm my transaction.

I measure confirmation time with Serum placeOrder/cancleOrder instruction.
both of them takes about 2s for submitting transaction, and both of them take about “20s” for confirming transaction. I can’t understand why there is such a long time to confirm.

1 Like

I am also experiencing very poor transaction confirmation speed and very large portion of failed transactions but maybe you could experiment with different commitments to speed up confirmation.

I think that might be normal. Waiting for full confirmation I think does take longer before the transactions is 100% finalized by receiving max confirmations from a supermajority of validators.

I’m pretty sure option number 1 is true, but like @igdeman said, you may need to adjust the commitment setting so that the command will return after the transaction has been confirmed, but before it has been finalized.’

Yeah, I have, maybe a few weeks ago, noticed that the network was very slow and almost unusable for a time. I think there are some performance issues that they still need to work out under some network conditions.

Thank you igdeman and zicklag! And specially thank you @zicklag for answering my questions every time. Enjoy the rest of your day!

1 Like