How make a timelock contract?

i am new and i am learning new things here. how will make a timelock contract.
if my token is
33% Presale
20% locked for 6months
20% locked for 1 yr
20% locked for 2yrs
7% burnable

1 Like

You can use the block.timestamp as a limit, such as

function releaseAfterSixMonths() public {
    require(block.timestamp >= DEPLOYED_TIME + 180 days);
}
2 Likes

Hi @Bsc_Talk,

You could create a TokenTimelock for each lockup period.

When creating token time locks or vesting you should consider prevention strategies for: Bypassing Smart Contract Timelocks.

1 Like

Actually i am learning new things. If i can get an example, it will be of great help.

MY CODE

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Detailed.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.5.0/contracts/token/ERC20/ERC20Burnable.sol";

contract Token is ERC20, ERC20Detailed, ERC20Burnable {

    constructor () public ERC20Detailed("Token", "TKN", 18) {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
  
}

And tried to use this timelockcode

But where to set release time. i am using remix-solidity.

i used this timelock code

pragma solidity ^0.5.0;

import "@openzeppelin/contracts/token/ERC20/TokenTimelock.sol";

contract SimpleTokenTimelock is TokenTimelock {
    constructor(IERC20 token, address beneficiary, uint256 releaseTime)
        public
        TokenTimelock(token, beneficiary, releaseTime)
    {}
}

And manually transferred 1000 test tokens to this contract address

And my verified contract

1 Like

Hi @Bsc_Talk,

Your approach sounds ok.

Please note, the latest version of OpenZeppelin Contracts 2.x is v2.5.1, whilst your token imports are for v2.5.0

I tried to read from your contract, but BscScan errors with:

Sorry, we were unable to retrieve a valid Contract ABI for this contract.
Unable to read contract information

You may need to contact BscScan to determine what the issue is.

2 posts were split to a new topic: BSC contract error