Created
September 4, 2019 16:48
-
-
Save critesjosh/5d0b3329cf1984468fb3bcca399cfa56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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