0
votes

I have a uint variable that contains days, through a function I wish I could have the ability to change but it gives me this error when I compile the code:

unexpected "days" after "time"

this is my code:

 uint public  cliff = 0 days;

 function changeCliff(uint time) public onlyOwner {
    cliff = time days;
}

how can i do it?

1

1 Answers

1
votes

These suffixes cannot be applied to variables. For example, if you want to interpret a function parameter in days, you can in the following way:

function f(uint start, uint daysAfter) public {
    if (block.timestamp >= start + daysAfter * 1 days) {
      // ...
    }
}

Source: docs

So applied to your code:

cliff = time * 1 days;