pragma solidity ^0.6.6;
import "./newERC20.sol";
contract TokenTimelock {
newERC20 token;
address beneficiary;
uint releaseTime;
function timelock(newERC20 _token, address _beneficiary, uint _releaseTime) public {
require(_releaseTime > now);
token = _token;
beneficiary = _beneficiary;
releaseTime = _releaseTime;
}
function claim() public {
require(msg.sender == beneficiary);
require(now >= releaseTime);
uint amount = token.balanceOf(this);
// what the purpose of using "uint amount" here, this amount produces an error
require(amount > 0);
token.transfer(beneficiary, amount);
}
}
Or can you share more ways to lock certain amount of tokens and release on a specific time.
balanceOfis expecting an address not the amount inuint– niksmac May 07 '20 at 12:04balanceOfproperty to find token balance? – sultan May 07 '20 at 12:13balanceOfcan be used to find the token balance andaddress(this).balanceto get ETH balance – niksmac May 07 '20 at 12:14newERC20, this is the ERC20 interface, and if i not import it in this code, so the code will executed properly? – sultan May 07 '20 at 12:29uint amount = token.balanceOf(amount), it is incorrect by any programming standard (Solidity or other), as you are attempting to use the variableamountwhile declaring it! – goodvibration May 07 '20 at 12:46