Skip to content

Instantly share code, notes, and snippets.

@critesjosh
Created September 4, 2019 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save critesjosh/5d0b3329cf1984468fb3bcca399cfa56 to your computer and use it in GitHub Desktop.
Save critesjosh/5d0b3329cf1984468fb3bcca399cfa56 to your computer and use it in GitHub Desktop.
pragma solidity ^0.5.0;
import "http://github.com/OpenZeppelin/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract ERC20Lockable is ERC20 {
mapping (address => uint) unlockTime;
mapping (address => bool) isLocked;
uint lockDuration = 1000;
modifier isNotLocked(){
if(isLocked[msg.sender]){
require(unlockTime[msg.sender] >= now, "Tokens are still locked.");
isLocked[msg.sender] = false;
}
_;
}
function lock() public
{
//require(isLocked[msg.sender] == false, "Tokens are already locked");
unlockTime[msg.sender] = now + lockDuration;
isLocked[msg.sender] = true;
}
function transfer(address recipient, uint256 amount) public isNotLocked() returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment