0

I'm trying to add a function that would publicly return the total amount of tokens a timelock contract is holding. I'm trying to call balanceOf address(this) from IERC20 but it's not compiling

pragma solidity ^0.8.0;

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


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

    constructor() TokenTimelock(myToken, myWallet, releasetime) {

    }

        function balanceOf(address this) external view returns (uint256);
        return balanceOf;
    }


}

1 Answer 1

1

To get the address of the current contract, you need to use address(this). There is no need to take any parameter in your function as your contract address is constant.

Try this, it directly reads the balance of your contract on the IERC20 interface held in your contract and returns it.

function currentBalance() external view returns (uint256) {
    return myToken.balanceOf(address(this));
}
0

Your Answer

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

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