curious why the require statement throws up Undeclared identifier in this solidity code:

pragma solidity ^0.4.8;

contract Escrow {
    modifier onlyafter(uint _time) {
      require(now >= _time);

I rewrote it as:

   modifier onlyafter(uint _time) {
      if(now >= _time){

which compiled fine.


require is available since Solidity 0.4.10: https://github.com/ethereum/solidity/releases

Since your pragma requires an older Solidity version this leads to a compiler error.

  • Thanks. Yes I tried to bump up the version in truffle but it was having none of it. Not a biggie but nice to know.
    – codervince
    Jun 16 '17 at 10:14
  • truffle sometimes lags a few compiler versions behind. I see that the currently latest version of truffle should ship with Solidity 0.4.11 so you should be fine if you update your pragma statement accordingly: github.com/trufflesuite/truffle/releases/tag/v3.2.2
    – SCBuergel
    Jun 17 '17 at 17:26

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.