I go through all functions in the API, but I didn't find how can I obtain a block slot number by block hash via Web3js.
2 Answers
There's no great way to do it unfortunately. The only possibility is to query the recent blockhashes sysvar account and see where yours falls on the list. It only maintains the last 150 blockhashes though.
Here's the sysvar in the explorer: https://explorer.solana.com/address/SysvarRecentB1ockHashes11111111111111111111/blockhashes
It might be useful to know that getLatestBlockHash returns both the latest blockhash and the slot for that blockhash.
This can be useful to track the number of slots between when a transaction is built (using latest blockhash) and when it lands on chain.