Edit: The answer below is for getting the slot/blockhash off-chain, and the question is for how to get the information on-chain within a program
You can get the slot like this:
const slot = await connection.getSlot()
Or get a recent blockhash like this:
const { blockhash, lastValidBlockHeight } =
await connection.getLatestBlockhash()