-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenLocker.sol
32 lines (24 loc) · 1.01 KB
/
tokenLocker.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pragma solidity ^0.5.0;
contract Token {
function transferFrom(address from, address to, uint256 value) public returns (bool){}
function transfer(address to, uint256 value) public returns (bool){}
}
contract Locker {
uint256 constant public expirationDate = 1630432800; // 1st September 2021
address public owner;
Token public token;
// provide token address to the locker constructor
constructor (address tokenAddress) public {
owner = msg.sender;
token = Token(tokenAddress);
}
function lockTokens(uint256 value) public returns(bool success) {
require(owner == msg.sender, "Only owner can lock tokens.");
token.transferFrom(msg.sender, address(this), value);
}
function withdrawTokens(uint256 value) public returns(bool success) {
require(owner == msg.sender, "Only owner can lock tokens.");
require(now <= expirationDate, "expirationDate is not reached yet");
token.transfer(msg.sender, value);
}
}