I'm creating a (very) simple token locking contract and wanted to incorporate a withdraw function to retrieve tokens sent to the contract by mistake. I have used this function in another contract with no problems, but seem to be getting an rpc error in remix for it here. I've pasted the contract below. If you let me know if you see anything I'd appreciate it. Any recommendations for that matter too, thanks
additional: testing on mumbai
contract TokenLocker is Ownable {
uint public lockDate;
uint public maxWithdraw;
ParentToken public tokenAddress;
constructor (ParentToken _tokenAddress){
tokenAddress = _tokenAddress;
maxWithdraw = tokenAddress.totalSupply() / 250;
}
function withdrawTokens(uint _amount) public onlyOwner {
require(block.timestamp == 0 || block.timestamp > lockDate + 1 weeks, "You cannot withdraw tokens yet");
require(_amount < maxWithdraw, "You cannot withdraw that quantity. Check the maxWithdraw function");
tokenAddress.transfer(owner(), _amount);
lockDate = block.timestamp;
}
//Retrieval of tokens incorrectly sent to contract. Locked token excluded.
function retrieveTokens(IERC20 token) external onlyOwner {
require(token != tokenAddress, "You cannot override the token lock");
uint256 balance = token.balanceOf(address(this));
require(balance > 0, "Contract has no balance");
require(token.transfer(owner(), balance), "Transfer failed");
}
function renounceOwnership() public view override onlyOwner {
revert("can't renounceOwnership here, mate");
}
receive() external payable {}
}