0

just wondering why I can't get this constructor to pass. What am i doing wrong ?

// SPDX-License-Identifier: MIT
// TeamLockTest

pragma solidity ^0.8.0;

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

contract TimeLockTest is TokenTimelock {
    constructor() TokenTimelock(0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4, 1654368599){

}

Solidity says "Function, variable, struct or modifier declaration expected"

1 Answer 1

0

The error is causes by TokenTimelock's first parameter. It's expecting a IERC20 parameter and you are passing an address instead. You have to convert the address to IERC20 and it should work:

For example something like this might work.

contract TimeLockTest is TokenTimelock {
    IERC20 constant myToken = IERC20(0x5B38Da6a701c568545dCfcB03FcB875f56beddC4);
    address constant myWallet = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;

    constructor() TokenTimelock(myToken, myWallet, 1654368599) {
    }
}
2
  • Amazing! Thank you! That worked. I was wondering if there would be a way to add a function that returns the number of tokens the contract is storing ? I tried calling function from the IERC20 but it failed. Nov 25, 2021 at 15:39
  • @Slimtradeywestcoast That is another question, it should be doable with IERC20, address(this) and balanceOf.
    – Ismael
    Nov 25, 2021 at 16:07

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.