Solidity – Locking a Certain Amount of Tokens

soliditytimelocktokens

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

Best Answer

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
Related Topic