Don't understand this overflow in my timelock

I have a timelock on an ERC20 contract, from year 0 to 9, it works until year 4, but from year 5 onwards it reverts. It fails both on minting and checking (Using 52 seconds instead of weeks for testing):

constructor() ERC20("Coin", "C") {        
    deploymentTime = block.timestamp;        

function checkMintDate(uint8 year) public view returns (uint256){
    return deploymentTime + 52 seconds * year;

function mint(uint8 year) public onlyOwner {        
    require (year <= 9, "cannot claim for more than 10 years");
    require(block.timestamp >= deploymentTime + 52 seconds * year, "Not that year yet");        
    require(!yearClaimed[year], "you already claimed that year");
    yearClaimed[year] = true;
    _mint(msg.sender, yearlyMintAmount);

When deployed to the testnet, remix gives this data, which is the overflow one:

"code": "3", "message": "execution reverted", "output": "0x4e487b710000000000000000000000000000000000000000000000000000000000000011"

Any ideas?, thanks!

If I change the "seconds" sufix to "years", the checkMintDate function passes with all the numbers, and returns the correct unix dates. But it keeps failing with "seconds", wtf...

The testnet tx:

Hey @pmk

What's the data type of seconds? I'd assume it's an overflow with year since it's uint8 with a 255 max.

Look at this:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract PoC {
    uint deploymentTime;

    constructor() {
        deploymentTime = block.timestamp;

    function mint(uint8 year) public {
        uint _test = 52 seconds * year;

mint will always fail, but if you change year to uint256, it starts passing.

Hope this helps :slight_smile:

1 Like