i am developing a locker smartcontract where user can send erc20 token and set time for locking period.for withdraw function i want to implement:
the locking time should passed
the address( wallet) lock the token can only withdraw
i am having difficulty to build the logic for withdraw function.
here is the code
pragma solidity ^0.8.7;
// SPDX-License-Identifier: MIT
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract lock {
address public owner;
struct Lock{
address token;
uint amount;
uint endtime;
}
constructor() {
owner= msg.sender;
}
mapping(address => Lock) public tokenLock;
function locker( address _token, uint256 _amount, uint _time) public{
tokenLock[msg.sender]= Lock(_token, _amount, _time);
IERC20(_token).transferFrom(msg.sender, address(this),_amount);
}
function chkBalance(address _token) public view returns (uint){
return IERC20(_token).balanceOf(address(this));
}
> function claim(address _token) public {
> require(block.timestamp >time);
>
> }
}