0

When I call the "setStartTime" function, it works but when I check "_startingTime" I get this error:

call to timeTracker._startingTime errored: Error encoding arguments: Error: invalid address (argument="address", value="", code=INVALID_ARGUMENT, version=address/5.1.0) (argument=null, value="", code=INVALID_ARGUMENT, version=abi/5.1.2)

Why am I getting this? If I am able to set time, then the mapping should have something to return?


contract timeTracker {

    mapping(address => uint256) public _startingTime;
    uint256 constant ONE_DAY = 86400;

    function setStartTime() public returns (uint time) {

        _startingTime[msg.sender] = block.timestamp;
        return _startingTime[msg.sender];
    }

    //checks if 24 hours have passed
    function checkIfDayPassed() public {
         //86400 seconds in a day
        require(block.timestamp - _startingTime[msg.sender] >= ONE_DAY, "Claim not ready");
  _startingTime[msg.sender] = block.timestamp;
    }
    
}
0

In your code above, _startingTime is defined as a mapping. When calling it, you need to pass it a correctly formatted address as an input for it to return anything meaningful. Apparently, you were calling it without passing in any value.

1
  • ah yeah, I see where I went wrong. I had thought that remix might have passed an address for me, but I had to enter it manually. Cheers! – Gabriel Jun 9 at 7:08

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.