I have made this smart contract test, but I need to add the function to prevent any wallet to transfer token until the first of January of 2018.

What would be the code needed to achieve this?


1 Answer 1


To prevent token transfer you have to add online of code in transfer and transferfrom function. require(now > 1514764800) This will check either the time was greater than Jan 01 2018 00:00:00 GMT or not, If it was greater than the specified time it will enable the function else it won't.

The disadvantage of adding a timestamp in the conditional statement is miners can fork the time. So if you are more concern about security add block number instead of timestamp.

function transfer( address _to, uint _value) public {
  require( now > 1514764800 );
  /* Rest of Function */

You can convert timestamp here.

  • 1
    Using a block number won't stop miners from making the thing fast-forward, as if they mess with timestamps the difficulty will adjust to make the blocks faster. Beyond very short timespans, if you want a time, use a timestamp. Oct 17, 2017 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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