3

I need to implement a timelock in my token. I was thinking about using the openzeppelin TokenTimelock.sol contract, but I am unsure how to implment it. When would this constructor function be called?

function TokenTimelock(ERC20Basic _token, address _beneficiary, uint256 _releaseTime) public {

Also I need to modify it so that I can create multiple time locks of certain amount of tokens per wallet.

e.g. - Lock 100 tokens on wallet 1 for 1 month - Lock 300 tokens on wallet 1 for 2 months - Lock 140 tokens on wallet 2 for 1 month etc

Are there any examples how this can be done?

Am I understanding it correctly that this is the way to use it: 1. Deploy the token timelock contract separately from the token, everytime you want to create a timelock. 2. Send an amount of tokens to this deployed contract address?

Thanks

1 Answer 1

3

Am I understanding it correctly that this is the way to use it: 1. Deploy the token timelock contract separately from the token, everytime you want to create a timelock. 2. Send an amount of tokens to this deployed contract address?

Yes, that is correct. You would do the following steps for your example:

  1. Deploy TokenTimelock with _releaseTime 1 month into the future. Let's assume this contract now lives at address 0x1ab
  2. Deploy TokenTimelock with _releaseTime 2 month into the future. Let's assume this contract now lives at address 0x2bc
  3. Deploy TokenTimelock with _releaseTime 1 month into the future. Let's assume this contract now lives at address 0x3cd
  4. send 100 tokens to 0x1ab
  5. send 300 tokens to 0x2bc
  6. send 140 tokens to 0x3cd
2
  • ok thanks, I guessed that is the way to do it. However, this would mean that the tokens will not be viewable in their wallets until they are released, right? Is there a way of integrating this so that locked tokens will appear in the wallet straight away?
    – koukotsu
    May 26, 2018 at 21:02
  • That's correct, these tokens wouldn't show up in the wallet balance. If that's the goal (feel free to ask this as a separate question) then you'd need to modify the tokens balanceOf or transfer and transferFrom functions which is a bit more messy (integrated into the Token contract with less separation of concerns).
    – SCBuergel
    May 27, 2018 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.