How to use TokenTimelock.sol to lock up tokens?

Hi @manipulator01
Welcome to the forum. It would be great if you could take a moment and Introduce yourself here! including a bit more about the game you are working on.

A TokenTimelock contract could look as follows:
What you didn’t have was inheriting from TokenTimelock (is TokenTimelock) and calling the TokenTimelock constructor with your desired values.

Once deployed, as you said, you would need to transfer the tokens to the timelock contract.

pragma solidity ^0.5.2;

import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/TokenTimelock.sol";


contract SimpleTokenTimelock is TokenTimelock {
    constructor () public TokenTimelock(
        IERC20(0xCfEB869F69431e42cdB54A4F4f105C19C080A601), // token
        0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b, // beneficiary
        1559075400) {
    }
}

If there isn’t an example, the tests can be good to look at to work out how a contract works. Though please ask all the questions that you need.

3 Likes