Skip to main content
added 148 characters in body
Source Link
john
  • 7.8k
  • 2
  • 10
  • 26

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()

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()

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()
Source Link
john
  • 7.8k
  • 2
  • 10
  • 26

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()