1

What is the formula for retrieving the blockhash of 1) previous block and of 2) current block?

  • You cannot get the block hash of the current block from inside the EVM. – Jesse Busman Apr 10 at 20:29
  • 1
    is that because it doesn't know the current block till it has been settled which means that it will be a past block anyway? – NowsyMe Apr 10 at 22:32
2

You can get the previous block's hash by using blockhash(block.number - 1). However, as mentioned in the comments, you cannot obtain the current block's header within that transaction because the transaction that is running has not been included in the block yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.