My code on Solidity is:
contract Recoverable is Ownable {
/// @dev Empty constructor (for now)
function Recoverable() public {
}
/// @dev This will be invoked by the owner, when owner wants to rescue tokens
/// @param token Token which will we rescue to the owner from the contract
function recoverTokens(ERC20Basic token) onlyOwner public {
token.transfer(owner, tokensToBeReturned(token));
}
/// @dev Interface function, can be overwritten by the superclass
/// @param token Token which balance we will check and return
/// @return The amount of tokens (in smallest denominator) the contract owns
function tokensToBeReturned(ERC20Basic token) public returns (uint) {
return token.balanceOf(this);
}
}
And I get next error: Function state mutability can be restricted to view
function tokensToBeReturned(ERC20Basic token) public returns (uint) {
^ (Relevant source part starts here and spans across multiple lines).
I take this example from GitHub, and when I try куdeclare a function as internal pure
, then get the next error:
function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
return token.balanceOf(this);
^--^
P.S. Help me, I really don`t understand.