I am trying to get a bit better performance for a game and would like to have the block hash already there when I send the transaction so I don't have to wait for the roundtrip to get it just before I send the transaction.

So best would be if I could socket subscribe to the latest block hash but seems this function is not available. Does anyone have experience with this?

I could poll the blockhash, but then I get rate limited quite quickly.

2 Answers 2


Blockhashes are valid for 150 slots which is roughly 60 seconds. You don't need to continually poll it to send transactions. You can fetch it roughly every minute and use it until it expires.

  • Will my transaction always end up in the next block no matter which recent block hash i put in? What is the blockhash used for? Do you know?
    – Jonas H.
    Commented Jan 8, 2023 at 10:41
  • 1
    It won't always end up in the next block if you put in a blockhash that's nonexistent or expired. As I mentioned in the post, a new blockhash is only valid for 150 slots. It's used to confirm that the transaction was signed and sent in a specific time period.
    – acheron
    Commented Jan 8, 2023 at 14:37

I ended up polling the latestBockhash every half a second and using the cached one for my transactions since the block hashes are valid for longer and apparently it does not need to be the latest even when the name implies that.

But there are some other options.

  1. subscribeBlock pushed the whole block data to the client and could be used to get a hash but it contains lots of data and the rpc may not support it. Maybe it could be filtered somehow, but I did not try that.

The more complicated approach from Solana break works like this as Jordash explained me is to send the transaction directly to the current leader. Sadly with the Introduction of QUIC it will probably not be possible anymore to push transactions directly to the TPU UDP port of the leader anymore.


Polling getClusterNodes is used to obtain https://solana-labs.github.io/solana-web3.js/types/ContactInfo.html which has the TPU address for nodes.

onSlotUpdate is used to track recent slots


This is combined with the leader schedule to determine the current leader

Sockets are opened to nodes


and raw signed transactions are sent over these sockets

A websocket from the server forwards to the TPU proxy


The client has a socket connection to the server to send transactions over

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.