Skip to main content

LennyTimelock

This LennyTimelock.sol is mainly inspired by the TokenTimelock.sol implemented by Openzeppelin. The main difference is that the token address can be set by the owners outside the constructor.

When the smart contract is created, the deployer decides the _beneficiary address and the _releaseTime. Then the total amount to be locked has to be sent to this smart contract. The only way to remove this amount is to wait the block timestamp to be greater than the _releaseTime timestamp.

Inheritances​

This contract inherits from the Context.sol and implementation from Openzeppelin, from Democratic.sol[Abstracts/Democratic.md].

Libraries​

This contract uses the SafeERC20.sol library implemented by Openzeppelin.

State Variables, Enums and Structs​

address private tokenAdd : address of the ERC20 token locked

address private immutable _beneficiary : address of the beneficiary.

address private immutable _releaseTime : timestamp at which token locked will be unlocked.

Functions​

constructor(address _doscAddress, address _beneficiary_, uint256 _releaseTime_) (public)​

To instantiate the smart contract, we provide the _doscAddress, the _beneficiary_ and the _releaseTime_. All instantiation are immutable.

changeTokenAddress(address newAddress) (external)​

The authorized administrator can call this function to change the address of the token locked in the smart contract. The reason why we added this extension is to be able to send back ERC20 token that could have been sent to this smart contract by error.

getTokenAddress() → address (public)​

Return the address of the token locked.

beneficiary() → address (public)​

Return the address of the beneficiary.

releaseTime() → uint256 (public)​

Returns the time when the tokens are released in seconds since Unix epoch

release() (external)​

Transfers tokens held by the timelock to the beneficiary. Will only succeed if invoked after the release time.

    function release() public virtual {
require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time");

uint256 amount = token().balanceOf(address(this));
require(amount > 0, "TokenTimelock: no tokens to release");

token().safeTransfer(beneficiary(), amount);
}