I have a transactional function that can only be called every few blocks, and I would like to create a view function that returns the number of blocks until the transactional function can be called again, in other words, current block minus block number of the last time the transactional function was called (which I keep track of in my contract state).

Is it possible to access the block.number inside a view function or can I only access it in a transactional function?

  • 1
    Wouldn't it have been easier to just try it rather than write this question?
    – user19510
    Aug 23 '18 at 16:23
  • If everybody tries every undocumented feature, no wonder why those languages and frameworks are so poorly documented.
    – Sebastien
    Aug 23 '18 at 16:37
  • Most team accept pull request to add more documentation.
    – Ismael
    Aug 24 '18 at 5:31

So indeed, after having tried this undocumented feature, I can confirm it is possible.

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.